acw 1.1.2 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dda66f075833c1878fa3bd2f35a27d92eaf0a9290ee519b131997b90fd00bc29
4
- data.tar.gz: 445c24100e91284c7bb62be7a66b8a8040f9f99c6c565d4e743e08f49229d781
3
+ metadata.gz: 3fa56b583e9d24bba42c1b75c166e1e92533525078f33d509593f06b03bded39
4
+ data.tar.gz: 82c5b800209aab1e0282918c9bda49768a96c95bb5ba6a7757156379da174f94
5
5
  SHA512:
6
- metadata.gz: 1b793e49061b1dd95860830c270a9d91ba22c8a14a3e976b3c36904d37516054feee0ef47378ad6f6cd58f1604ef3f9f8087d6a817cb603b16606ad1a2deda98
7
- data.tar.gz: 52c0e6116c71b98fbefea9be9da18a9baf75f8bba7b104a7239cd92f3e739f2898edd08d4dbf0351bb447deedb37385d96b81b6c9378c9cd9ff7cc1a3f20e8ed
6
+ metadata.gz: 575847d2ebddd5c197e85adf24efdc01eaf147ce10b6cc57d5dd7ef61fa51965865b20ce2cd3cc0c99beab07dfe03891f5c3f9b736112169cb442a73589fe19f
7
+ data.tar.gz: 8d7b0b30a4ffa3977f346cf0bb5a1dc1eb36a1ae22d1281877586bf279b4503fcb04b9d4117a7b77bf1791b78c1d0f4a30c65dc8917638c39bee4893554fca58
@@ -1,22 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acw (1.1.2)
5
- faraday (>= 1.0)
4
+ acw (1.2.0)
5
+ excon (>= 0.73.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  addressable (2.7.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
+ coderay (1.1.3)
12
13
  crack (0.4.3)
13
14
  safe_yaml (~> 1.0.0)
14
15
  diff-lcs (1.3)
15
- faraday (1.2.0)
16
- multipart-post (>= 1.2, < 3)
17
- ruby2_keywords
16
+ excon (0.78.1)
18
17
  hashdiff (1.0.1)
19
- multipart-post (2.1.1)
18
+ method_source (1.0.0)
19
+ pry (0.13.1)
20
+ coderay (~> 1.1)
21
+ method_source (~> 1.0)
20
22
  public_suffix (4.0.4)
21
23
  rake (12.3.3)
22
24
  rspec (3.9.0)
@@ -32,7 +34,6 @@ GEM
32
34
  diff-lcs (>= 1.2.0, < 2.0)
33
35
  rspec-support (~> 3.9.0)
34
36
  rspec-support (3.9.2)
35
- ruby2_keywords (0.0.2)
36
37
  safe_yaml (1.0.5)
37
38
  vcr (5.1.0)
38
39
  webmock (3.8.3)
@@ -46,6 +47,7 @@ PLATFORMS
46
47
  DEPENDENCIES
47
48
  acw!
48
49
  bundler (~> 2.0)
50
+ pry (~> 0.13.1)
49
51
  rake (~> 12.3.3)
50
52
  rspec (~> 3.0)
51
53
  vcr (~> 5.1)
@@ -28,11 +28,13 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
30
 
31
- spec.add_dependency 'faraday', '>= 1.0'
31
+ # spec.add_dependency 'faraday', '>= 1.0'
32
+ spec.add_dependency 'excon', '>= 0.73.0'
32
33
 
33
34
  spec.add_development_dependency "bundler", "~> 2.0"
34
35
  spec.add_development_dependency "rake", "~> 12.3.3"
35
36
  spec.add_development_dependency "rspec", "~> 3.0"
36
37
  spec.add_development_dependency "vcr", "~> 5.1"
37
38
  spec.add_development_dependency "webmock", "~> 3.8"
39
+ spec.add_development_dependency 'pry', '~> 0.13.1'
38
40
  end
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'faraday'
3
+ require 'excon'
4
4
  require 'cgi'
5
5
  require 'json'
6
+ require 'pry'
6
7
 
7
8
  module Acw
8
9
  class Client
10
+ API_VERSION = 3
9
11
  Result = Struct.new(:success?, :error, :value)
10
12
 
11
13
  def initialize(configs = {})
@@ -15,46 +17,49 @@ module Acw
15
17
  attr_reader :config
16
18
 
17
19
  def connection
18
- @connection ||= Faraday.new(url: config[:url]) do |faraday|
19
- faraday.headers['Accept'] = 'application/json'
20
- faraday.headers['Content-Type'] = 'application/json'
21
- faraday.headers['Api-Token'] = config[:token]
22
- faraday
23
- end
20
+ @connection ||= Excon.new(config[:url])
24
21
  end
25
22
 
26
23
  # CONTACTS
27
24
  def create_contact(args={})
28
25
  safe_http_call do
29
26
  params = { contact: args }
30
- connection.post('contacts', params.to_json)
27
+ connection.post(
28
+ path: "/api/#{API_VERSION}/contacts",
29
+ headers: headers,
30
+ body: params.to_json
31
+ )
31
32
  end
32
33
  end
33
34
 
34
35
  def sync_contact(args = {})
35
36
  safe_http_call do
36
37
  params = { contact: args }
37
- connection.post('contact/sync', params.to_json)
38
+ connection.post(
39
+ path: "/api/#{API_VERSION}/contact/sync",
40
+ headers: headers,
41
+ body: params.to_json
42
+ )
38
43
  end
39
44
  end
40
45
 
41
46
  def retrieve_contact(id)
42
47
  safe_http_call do
43
- connection.get("contacts/#{id}")
48
+ connection.get(path: "/api/#{API_VERSION}/contacts/#{id}", headers: headers)
44
49
  end
45
50
  end
46
51
 
47
52
  def retrieve_contact_by_email(email)
48
53
  safe_http_call do
49
54
  uemail = CGI.escape email
50
- connection.get("contacts?search=#{uemail}")
55
+ connection.get(path: "/api/#{API_VERSION}/contacts?search=#{uemail}", headers: headers)
51
56
  end
52
57
  end
53
58
 
54
59
  # LISTS
55
60
  def retrieve_lists
56
61
  safe_http_call do
57
- connection.get('lists')
62
+ connection.get(path: "/api/#{API_VERSION}/lists", headers: headers)
58
63
  end
59
64
  end
60
65
 
@@ -62,25 +67,41 @@ module Acw
62
67
  def create_tag(args = {})
63
68
  safe_http_call do
64
69
  params = { 'tag': args }
65
- connection.post('tags', params.to_json)
70
+ connection.post(
71
+ path: "/api/#{API_VERSION}/tags",
72
+ headers: headers,
73
+ body: params.to_json
74
+ )
66
75
  end
67
76
  end
68
77
 
69
78
  def add_contact_tag(args = {})
70
79
  safe_http_call do
71
80
  params = { 'contactTag': args }
72
- connection.post('contactTags', params.to_json)
81
+ connection.post(
82
+ path: "/api/#{API_VERSION}/contactTags",
83
+ headers: headers,
84
+ body: params.to_json
85
+ )
73
86
  end
74
87
  end
75
88
 
76
89
  def remove_contact_tag(id)
77
90
  safe_http_call do
78
- connection.delete("contactTags/#{id}")
91
+ connection.delete(path: "/api/#{API_VERSION}/contactTags/#{id}", headers: headers)
79
92
  end
80
93
  end
81
94
 
82
95
  private
83
96
 
97
+ def headers
98
+ {
99
+ 'Accept': 'application/json',
100
+ 'Content-Type': 'application/json',
101
+ 'Api-Token': config[:token]
102
+ }
103
+ end
104
+
84
105
  def safe_http_call
85
106
  response = yield
86
107
  raise response.body unless success_http_status(response.status)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Acw
4
- VERSION = '1.1.2'
4
+ VERSION = '1.2.0'
5
5
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anchieta Júnior
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-24 00:00:00.000000000 Z
11
+ date: 2020-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: faraday
14
+ name: excon
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: 0.73.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: 0.73.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.13.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.13.1
97
111
  description: Active Campaign Wrapper.
98
112
  email:
99
113
  - santosjr87@gmail.com
@@ -138,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
152
  - !ruby/object:Gem::Version
139
153
  version: '0'
140
154
  requirements: []
141
- rubygems_version: 3.0.8
155
+ rubygems_version: 3.1.4
142
156
  signing_key:
143
157
  specification_version: 4
144
158
  summary: Active Campaign Wrapper.