beeiq_api 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/beeiq_api/contact.rb +60 -0
- data/lib/beeiq_api/ticket.rb +1 -1
- data/lib/beeiq_api/version.rb +1 -1
- data/lib/beeiq_api.rb +33 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab4104a63fc9c383558f864eb870996ed52e231b
|
4
|
+
data.tar.gz: e66d5a81b0857a266e19ad47482ec98f06c23a31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27709f7d52be2654ffd6fe0835e087ef32044b8bec86015277b728a99ad66b3ccfee004b386a5c4e59b1bb29af89329ecde15d3ddffbbfa207d044526a086935
|
7
|
+
data.tar.gz: 243180d9f433687294907d1aca7196410ddbd61814962716c054443f4d34b911f2a1cd516cbf4edbfc691115d96e5fe1ec8c0bc3054074b57769281d0c577bae
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module BeeiqAPI
|
2
|
+
class Contact
|
3
|
+
attr_accessor :contact_type
|
4
|
+
attr_accessor :name
|
5
|
+
attr_accessor :lastname
|
6
|
+
attr_accessor :title
|
7
|
+
attr_accessor :passport
|
8
|
+
attr_accessor :gender
|
9
|
+
attr_accessor :date_of_birth
|
10
|
+
attr_accessor :emails
|
11
|
+
attr_accessor :phones
|
12
|
+
attr_accessor :addresses
|
13
|
+
attr_accessor :im
|
14
|
+
attr_accessor :tag
|
15
|
+
attr_accessor :cus_fields
|
16
|
+
attr_accessor :company_contact
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
@contact_type = options[:contact_type] || Config::ContactType::CUSTOMER
|
20
|
+
@name = options[:name]
|
21
|
+
@lastname = options[:lastname]
|
22
|
+
@title = options[:title]
|
23
|
+
@passport = options[:passport]
|
24
|
+
@gender = options[:gender]
|
25
|
+
@date_of_birth = options[:date_of_birth]
|
26
|
+
@emails = options[:emails]
|
27
|
+
@phones = options[:phones]
|
28
|
+
@addresses = options[:addresses]
|
29
|
+
@im = options[:im]
|
30
|
+
@tag = options[:tag]
|
31
|
+
@cus_fields = options[:cus_fields]
|
32
|
+
@company_contact = options[:company_contact]
|
33
|
+
|
34
|
+
raise ArgumentError, 'name is required' if @name.to_s.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def payload_raw
|
38
|
+
{
|
39
|
+
contactType: @contact_type,
|
40
|
+
name: @name,
|
41
|
+
lastname: @lastname,
|
42
|
+
title: @title,
|
43
|
+
passport: @passport,
|
44
|
+
gender: @gender,
|
45
|
+
dateOfBirth: @date_of_birth,
|
46
|
+
emails: @emails,
|
47
|
+
phones: @phones,
|
48
|
+
addresses: @addresses,
|
49
|
+
im: @im,
|
50
|
+
tag: @tag,
|
51
|
+
cusFields: @cus_fields,
|
52
|
+
companyContact: @company_contact
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def payload
|
57
|
+
payload_raw.delete_if { |k, v| v.nil? || (!v.kind_of?(Integer) && v.empty?) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/beeiq_api/ticket.rb
CHANGED
@@ -14,7 +14,7 @@ module BeeiqAPI
|
|
14
14
|
attr_accessor :tag
|
15
15
|
|
16
16
|
def initialize(options = {})
|
17
|
-
@
|
17
|
+
@contact_type = options[:contact_type] || Config::ContactType::CUSTOMER
|
18
18
|
@title = options[:title]
|
19
19
|
@body = options[:body]
|
20
20
|
@email = options[:email]
|
data/lib/beeiq_api/version.rb
CHANGED
data/lib/beeiq_api.rb
CHANGED
@@ -2,6 +2,7 @@ require "beeiq_api/version"
|
|
2
2
|
require "beeiq_api/config"
|
3
3
|
require "beeiq_api/response"
|
4
4
|
require "beeiq_api/ticket"
|
5
|
+
require "beeiq_api/contact"
|
5
6
|
require 'configuration'
|
6
7
|
require 'rest-client'
|
7
8
|
require 'json'
|
@@ -29,7 +30,26 @@ module BeeiqAPI
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def create_many_ticket(data = [])
|
32
|
-
|
33
|
+
create_or_update_contact(Config::ActionType::ADD_TICKET, data)
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_contact(data = {})
|
37
|
+
create_many_contact([data])
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_many_contact(data = [])
|
41
|
+
end
|
42
|
+
|
43
|
+
def update_contact(data = {})
|
44
|
+
update_many_contact([data])
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_many_contact(data = [])
|
48
|
+
create_or_update_contact(Config::ActionType::UPDATE_CONTACT, data)
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_or_update_contact(action, data)
|
52
|
+
payload = build_payload(action, data)
|
33
53
|
process(:post, payload)
|
34
54
|
end
|
35
55
|
|
@@ -38,6 +58,8 @@ module BeeiqAPI
|
|
38
58
|
case action
|
39
59
|
when Config::ActionType::ADD_TICKET
|
40
60
|
build_ticket_payload(data)
|
61
|
+
when Config::ActionType::ADD_CONTACT, Config::ActionType::UPDATE_CONTACT
|
62
|
+
build_contact_payload(action, data)
|
41
63
|
end
|
42
64
|
|
43
65
|
{
|
@@ -56,6 +78,16 @@ module BeeiqAPI
|
|
56
78
|
end
|
57
79
|
end
|
58
80
|
|
81
|
+
def build_contact_payload(action, data)
|
82
|
+
data.map do |item|
|
83
|
+
contact = BeeiqAPI::Contact.new item
|
84
|
+
{
|
85
|
+
actionType: action,
|
86
|
+
data: contact.payload
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
59
91
|
private
|
60
92
|
|
61
93
|
def process(verb, data=nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beeiq_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huy Hùng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- bin/setup
|
103
103
|
- lib/beeiq_api.rb
|
104
104
|
- lib/beeiq_api/config.rb
|
105
|
+
- lib/beeiq_api/contact.rb
|
105
106
|
- lib/beeiq_api/response.rb
|
106
107
|
- lib/beeiq_api/ticket.rb
|
107
108
|
- lib/beeiq_api/version.rb
|