acw 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fa56b583e9d24bba42c1b75c166e1e92533525078f33d509593f06b03bded39
4
- data.tar.gz: 82c5b800209aab1e0282918c9bda49768a96c95bb5ba6a7757156379da174f94
3
+ metadata.gz: d6f83ffb21109941cf55bca7475d4efcea6864dba7e5f60e7db3b00cea5fe935
4
+ data.tar.gz: 26469ac00550599f941d1b33c7365d46e21c7a520c248e52ebb91896ee436e76
5
5
  SHA512:
6
- metadata.gz: 575847d2ebddd5c197e85adf24efdc01eaf147ce10b6cc57d5dd7ef61fa51965865b20ce2cd3cc0c99beab07dfe03891f5c3f9b736112169cb442a73589fe19f
7
- data.tar.gz: 8d7b0b30a4ffa3977f346cf0bb5a1dc1eb36a1ae22d1281877586bf279b4503fcb04b9d4117a7b77bf1791b78c1d0f4a30c65dc8917638c39bee4893554fca58
6
+ metadata.gz: f4b5556926b458da090b34b9dec09bd4516a26bdaf0810f5956d8358c3105d9ccd5789e4cfab73436791acb4d59db16d161461886ce9fa7d5da9e55ef3c1d621
7
+ data.tar.gz: b2691fc0ca83aa1ecb76d5a2f98142027a505dac183536e45c7c96797b4a9cf70cf8aba331b66fc5ab1de334a47cb7c373581ab4d0b5894b918a459e25a9cab6
@@ -0,0 +1,2 @@
1
+ Style/Documentation:
2
+ Enabled: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acw (1.2.0)
4
+ acw (1.3.0)
5
5
  excon (>= 0.73.0)
6
6
 
7
7
  GEM
@@ -9,18 +9,38 @@ GEM
9
9
  specs:
10
10
  addressable (2.7.0)
11
11
  public_suffix (>= 2.0.2, < 5.0)
12
+ ast (2.4.1)
13
+ backport (1.1.2)
14
+ benchmark (0.1.1)
12
15
  coderay (1.1.3)
13
16
  crack (0.4.3)
14
17
  safe_yaml (~> 1.0.0)
15
18
  diff-lcs (1.3)
19
+ e2mmap (0.1.0)
16
20
  excon (0.78.1)
17
21
  hashdiff (1.0.1)
22
+ jaro_winkler (1.5.4)
23
+ kramdown (2.3.0)
24
+ rexml
25
+ kramdown-parser-gfm (1.1.0)
26
+ kramdown (~> 2.0)
18
27
  method_source (1.0.0)
28
+ mini_portile2 (2.4.0)
29
+ nokogiri (1.10.10)
30
+ mini_portile2 (~> 2.4.0)
31
+ parallel (1.20.1)
32
+ parser (2.7.2.0)
33
+ ast (~> 2.4.1)
19
34
  pry (0.13.1)
20
35
  coderay (~> 1.1)
21
36
  method_source (~> 1.0)
22
37
  public_suffix (4.0.4)
38
+ rainbow (3.0.0)
23
39
  rake (12.3.3)
40
+ regexp_parser (2.0.3)
41
+ reverse_markdown (2.0.0)
42
+ nokogiri
43
+ rexml (3.2.4)
24
44
  rspec (3.9.0)
25
45
  rspec-core (~> 3.9.0)
26
46
  rspec-expectations (~> 3.9.0)
@@ -34,12 +54,42 @@ GEM
34
54
  diff-lcs (>= 1.2.0, < 2.0)
35
55
  rspec-support (~> 3.9.0)
36
56
  rspec-support (3.9.2)
57
+ rubocop (1.7.0)
58
+ parallel (~> 1.10)
59
+ parser (>= 2.7.1.5)
60
+ rainbow (>= 2.2.2, < 4.0)
61
+ regexp_parser (>= 1.8, < 3.0)
62
+ rexml
63
+ rubocop-ast (>= 1.2.0, < 2.0)
64
+ ruby-progressbar (~> 1.7)
65
+ unicode-display_width (>= 1.4.0, < 2.0)
66
+ rubocop-ast (1.3.0)
67
+ parser (>= 2.7.1.5)
68
+ ruby-progressbar (1.10.1)
37
69
  safe_yaml (1.0.5)
70
+ solargraph (0.40.1)
71
+ backport (~> 1.1)
72
+ benchmark
73
+ bundler (>= 1.17.2)
74
+ e2mmap
75
+ jaro_winkler (~> 1.5)
76
+ kramdown (~> 2.3)
77
+ kramdown-parser-gfm (~> 1.1)
78
+ parser (~> 2.3)
79
+ reverse_markdown (>= 1.0.5, < 3)
80
+ rubocop (>= 0.52)
81
+ thor (~> 1.0)
82
+ tilt (~> 2.0)
83
+ yard (~> 0.9, >= 0.9.24)
84
+ thor (1.0.1)
85
+ tilt (2.0.10)
86
+ unicode-display_width (1.7.0)
38
87
  vcr (5.1.0)
39
88
  webmock (3.8.3)
40
89
  addressable (>= 2.3.6)
41
90
  crack (>= 0.3.2)
42
91
  hashdiff (>= 0.4.0, < 2.0.0)
92
+ yard (0.9.26)
43
93
 
44
94
  PLATFORMS
45
95
  ruby
@@ -50,6 +100,8 @@ DEPENDENCIES
50
100
  pry (~> 0.13.1)
51
101
  rake (~> 12.3.3)
52
102
  rspec (~> 3.0)
103
+ rubocop (~> 1.7)
104
+ solargraph (~> 0.40)
53
105
  vcr (~> 5.1)
54
106
  webmock (~> 3.8)
55
107
 
data/README.md CHANGED
@@ -35,7 +35,7 @@ client = Acw::Client.new({
35
35
  client.connection
36
36
  ```
37
37
 
38
- > ### Create contact
38
+ > ### Create contact - [Api Reference](https://developers.activecampaign.com/reference#create-a-contact-new)
39
39
 
40
40
  ```ruby
41
41
  client.create_contact({
@@ -46,7 +46,7 @@ client.create_contact({
46
46
  })
47
47
  ```
48
48
 
49
- > ### Sync contact (Create or Update)
49
+ > ### Sync contact (Create or Update) - [Api Reference](https://developers.activecampaign.com/reference#create-or-update-contact-new)
50
50
 
51
51
  ```ruby
52
52
  client.sync_contact({
@@ -57,7 +57,7 @@ client.sync_contact({
57
57
  })
58
58
  ```
59
59
 
60
- > ### Retrieve contact
60
+ > ### Retrieve contact - [Api Reference](https://developers.activecampaign.com/reference#get-contact)
61
61
 
62
62
  ```ruby
63
63
  client.retrieve_contact("contact_id")
@@ -71,13 +71,13 @@ This will return an array of contacts.
71
71
  client.retrieve_contact_by_email("email")
72
72
  ```
73
73
 
74
- > ### Retrieve lists
74
+ > ### Retrieve lists - [Api Reference](https://developers.activecampaign.com/reference#retrieve-all-lists)
75
75
 
76
76
  ```ruby
77
77
  client.retrieve_lists
78
78
  ```
79
79
 
80
- > ### Create tag
80
+ > ### Create tag - [Api Reference](https://developers.activecampaign.com/reference#tags)
81
81
 
82
82
  ```ruby
83
83
  client.create_tag({
@@ -85,7 +85,7 @@ client.create_tag({
85
85
  })
86
86
  ```
87
87
 
88
- > ### Add a tag to contact
88
+ > ### Add a tag to contact - [Api Reference](https://developers.activecampaign.com/reference#create-contact-tag)
89
89
 
90
90
  It generates a relationship called contactTag containing an id.
91
91
 
@@ -95,7 +95,7 @@ client.add_contact_tag({
95
95
  })
96
96
  ```
97
97
 
98
- > ### Remove a tag to contact
98
+ > ### Remove a tag to contact - [Api Reference](https://developers.activecampaign.com/reference#delete-contact-tag)
99
99
 
100
100
  To remove a tag from contact just remove the relationship between them.
101
101
 
@@ -103,6 +103,44 @@ To remove a tag from contact just remove the relationship between them.
103
103
  client.remove_contact_tag("contact_tag_id)
104
104
  ```
105
105
 
106
+ > ### Create field value - [Api Reference](https://developers.activecampaign.com/reference#create-fieldvalue)
107
+
108
+ It generates a relationship called fieldVaalue containing an id.
109
+
110
+ ```ruby
111
+ client.create_field_value(
112
+ {
113
+ contact: 572218,
114
+ field: 2,
115
+ value: 'field_value'
116
+ }
117
+ )
118
+ ```
119
+
120
+ > ### Update a field value - [Api Reference](https://developers.activecampaign.com/reference#update-a-custom-field-value-for-contact)
121
+
122
+ It updates a relationship called fieldVaalue containing an id.
123
+
124
+ ```ruby
125
+ client.update_field_value(
126
+ 803_383,
127
+ {
128
+ contact: 572218,
129
+ field: 2,
130
+ value: 'new_field_value_put'
131
+ }
132
+ )
133
+ ```
134
+
135
+ ## Testing with your Api-Token
136
+
137
+ You can disable vcr in specs with these commands in your tests and create a new context for you.
138
+
139
+ ```
140
+ WebMock.allow_net_connect!
141
+ VCR.turn_off!
142
+ ```
143
+
106
144
  ## License
107
145
 
108
146
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -37,4 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency "vcr", "~> 5.1"
38
38
  spec.add_development_dependency "webmock", "~> 3.8"
39
39
  spec.add_development_dependency 'pry', '~> 0.13.1'
40
+ spec.add_development_dependency 'solargraph', '~> 0.40'
41
+ spec.add_development_dependency 'rubocop', '~> 1.7'
40
42
  end
data/lib/acw.rb CHANGED
@@ -1,5 +1,7 @@
1
- require "acw/version"
2
- require "acw/client"
1
+ # frozen_string_literal: true
2
+
3
+ require 'acw/version'
4
+ require 'acw/client'
3
5
 
4
6
  module Acw
5
7
  module_function
@@ -3,7 +3,6 @@
3
3
  require 'excon'
4
4
  require 'cgi'
5
5
  require 'json'
6
- require 'pry'
7
6
 
8
7
  module Acw
9
8
  class Client
@@ -21,7 +20,7 @@ module Acw
21
20
  end
22
21
 
23
22
  # CONTACTS
24
- def create_contact(args={})
23
+ def create_contact(args = {})
25
24
  safe_http_call do
26
25
  params = { contact: args }
27
26
  connection.post(
@@ -66,7 +65,7 @@ module Acw
66
65
  # TAGS
67
66
  def create_tag(args = {})
68
67
  safe_http_call do
69
- params = { 'tag': args }
68
+ params = { tag: args }
70
69
  connection.post(
71
70
  path: "/api/#{API_VERSION}/tags",
72
71
  headers: headers,
@@ -92,6 +91,29 @@ module Acw
92
91
  end
93
92
  end
94
93
 
94
+ # FIELD_VALUES
95
+ def create_field_value(args = {})
96
+ safe_http_call do
97
+ params = { 'fieldValue': args }
98
+ connection.post(
99
+ path: "/api/#{API_VERSION}/fieldValues",
100
+ headers: headers,
101
+ body: params.to_json
102
+ )
103
+ end
104
+ end
105
+
106
+ def update_field_value(id, args = {})
107
+ safe_http_call do
108
+ params = { 'fieldValue': args }
109
+ connection.put(
110
+ path: "/api/#{API_VERSION}/fieldValues/#{id}",
111
+ headers: headers,
112
+ body: params.to_json
113
+ )
114
+ end
115
+ end
116
+
95
117
  private
96
118
 
97
119
  def headers
@@ -112,7 +134,7 @@ module Acw
112
134
  end
113
135
 
114
136
  def success_http_status(status)
115
- [200, 201].include?(status)
137
+ [200, 201, 202].include?(status)
116
138
  end
117
139
  end
118
140
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Acw
4
- VERSION = '1.2.0'
4
+ VERSION = '1.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.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-25 00:00:00.000000000 Z
11
+ date: 2020-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -108,6 +108,34 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.13.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: solargraph
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.40'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.40'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.7'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.7'
111
139
  description: Active Campaign Wrapper.
112
140
  email:
113
141
  - santosjr87@gmail.com
@@ -118,6 +146,7 @@ files:
118
146
  - ".github/workflows/ci.yml"
119
147
  - ".gitignore"
120
148
  - ".rspec"
149
+ - ".rubocop.yml"
121
150
  - Gemfile
122
151
  - Gemfile.lock
123
152
  - LICENSE.txt
@@ -152,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
181
  - !ruby/object:Gem::Version
153
182
  version: '0'
154
183
  requirements: []
155
- rubygems_version: 3.1.4
184
+ rubygems_version: 3.0.8
156
185
  signing_key:
157
186
  specification_version: 4
158
187
  summary: Active Campaign Wrapper.