acw 0.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -6
- data/README.md +0 -5
- data/acw.gemspec +2 -2
- data/lib/acw/client.rb +21 -19
- data/lib/acw/version.rb +3 -1
- metadata +8 -15
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dda66f075833c1878fa3bd2f35a27d92eaf0a9290ee519b131997b90fd00bc29
|
4
|
+
data.tar.gz: 445c24100e91284c7bb62be7a66b8a8040f9f99c6c565d4e743e08f49229d781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b793e49061b1dd95860830c270a9d91ba22c8a14a3e976b3c36904d37516054feee0ef47378ad6f6cd58f1604ef3f9f8087d6a817cb603b16606ad1a2deda98
|
7
|
+
data.tar.gz: 52c0e6116c71b98fbefea9be9da18a9baf75f8bba7b104a7239cd92f3e739f2898edd08d4dbf0351bb447deedb37385d96b81b6c9378c9cd9ff7cc1a3f20e8ed
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
acw (
|
5
|
-
faraday (>= 1.0
|
4
|
+
acw (1.1.2)
|
5
|
+
faraday (>= 1.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -12,12 +12,13 @@ GEM
|
|
12
12
|
crack (0.4.3)
|
13
13
|
safe_yaml (~> 1.0.0)
|
14
14
|
diff-lcs (1.3)
|
15
|
-
faraday (1.0
|
15
|
+
faraday (1.2.0)
|
16
16
|
multipart-post (>= 1.2, < 3)
|
17
|
+
ruby2_keywords
|
17
18
|
hashdiff (1.0.1)
|
18
19
|
multipart-post (2.1.1)
|
19
20
|
public_suffix (4.0.4)
|
20
|
-
rake (
|
21
|
+
rake (12.3.3)
|
21
22
|
rspec (3.9.0)
|
22
23
|
rspec-core (~> 3.9.0)
|
23
24
|
rspec-expectations (~> 3.9.0)
|
@@ -31,6 +32,7 @@ GEM
|
|
31
32
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
33
|
rspec-support (~> 3.9.0)
|
33
34
|
rspec-support (3.9.2)
|
35
|
+
ruby2_keywords (0.0.2)
|
34
36
|
safe_yaml (1.0.5)
|
35
37
|
vcr (5.1.0)
|
36
38
|
webmock (3.8.3)
|
@@ -44,10 +46,10 @@ PLATFORMS
|
|
44
46
|
DEPENDENCIES
|
45
47
|
acw!
|
46
48
|
bundler (~> 2.0)
|
47
|
-
rake (~>
|
49
|
+
rake (~> 12.3.3)
|
48
50
|
rspec (~> 3.0)
|
49
51
|
vcr (~> 5.1)
|
50
52
|
webmock (~> 3.8)
|
51
53
|
|
52
54
|
BUNDLED WITH
|
53
|
-
2.
|
55
|
+
2.1.4
|
data/README.md
CHANGED
data/acw.gemspec
CHANGED
@@ -28,10 +28,10 @@ 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
32
|
|
33
33
|
spec.add_development_dependency "bundler", "~> 2.0"
|
34
|
-
spec.add_development_dependency "rake", "~>
|
34
|
+
spec.add_development_dependency "rake", "~> 12.3.3"
|
35
35
|
spec.add_development_dependency "rspec", "~> 3.0"
|
36
36
|
spec.add_development_dependency "vcr", "~> 5.1"
|
37
37
|
spec.add_development_dependency "webmock", "~> 3.8"
|
data/lib/acw/client.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'faraday'
|
2
4
|
require 'cgi'
|
3
5
|
require 'json'
|
4
6
|
|
5
7
|
module Acw
|
6
8
|
class Client
|
7
|
-
|
8
9
|
Result = Struct.new(:success?, :error, :value)
|
9
10
|
|
10
11
|
def initialize(configs = {})
|
@@ -15,25 +16,25 @@ module Acw
|
|
15
16
|
|
16
17
|
def connection
|
17
18
|
@connection ||= Faraday.new(url: config[:url]) do |faraday|
|
18
|
-
faraday.headers[
|
19
|
+
faraday.headers['Accept'] = 'application/json'
|
19
20
|
faraday.headers['Content-Type'] = 'application/json'
|
20
21
|
faraday.headers['Api-Token'] = config[:token]
|
21
22
|
faraday
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
#CONTACTS
|
26
|
+
# CONTACTS
|
26
27
|
def create_contact(args={})
|
27
28
|
safe_http_call do
|
28
29
|
params = { contact: args }
|
29
|
-
connection.post(
|
30
|
+
connection.post('contacts', params.to_json)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
def sync_contact(args={})
|
34
|
+
def sync_contact(args = {})
|
34
35
|
safe_http_call do
|
35
36
|
params = { contact: args }
|
36
|
-
connection.post(
|
37
|
+
connection.post('contact/sync', params.to_json)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
@@ -50,28 +51,28 @@ module Acw
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
#LISTS
|
54
|
+
# LISTS
|
54
55
|
def retrieve_lists
|
55
56
|
safe_http_call do
|
56
|
-
connection.get(
|
57
|
+
connection.get('lists')
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
60
|
-
#TAGS
|
61
|
-
def create_tag(args={})
|
61
|
+
# TAGS
|
62
|
+
def create_tag(args = {})
|
62
63
|
safe_http_call do
|
63
|
-
params = {
|
64
|
-
connection.post(
|
64
|
+
params = { 'tag': args }
|
65
|
+
connection.post('tags', params.to_json)
|
65
66
|
end
|
66
67
|
end
|
67
|
-
|
68
|
-
def add_contact_tag(args={})
|
68
|
+
|
69
|
+
def add_contact_tag(args = {})
|
69
70
|
safe_http_call do
|
70
|
-
params = {
|
71
|
-
connection.post(
|
71
|
+
params = { 'contactTag': args }
|
72
|
+
connection.post('contactTags', params.to_json)
|
72
73
|
end
|
73
74
|
end
|
74
|
-
|
75
|
+
|
75
76
|
def remove_contact_tag(id)
|
76
77
|
safe_http_call do
|
77
78
|
connection.delete("contactTags/#{id}")
|
@@ -83,13 +84,14 @@ module Acw
|
|
83
84
|
def safe_http_call
|
84
85
|
response = yield
|
85
86
|
raise response.body unless success_http_status(response.status)
|
87
|
+
|
86
88
|
Result.new(true, nil, JSON.parse(response.body))
|
87
89
|
rescue StandardError => e
|
88
90
|
Result.new(false, e.message, nil)
|
89
91
|
end
|
90
92
|
|
91
93
|
def success_http_status(status)
|
92
|
-
|
94
|
+
[200, 201].include?(status)
|
93
95
|
end
|
94
96
|
end
|
95
|
-
end
|
97
|
+
end
|
data/lib/acw/version.rb
CHANGED
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:
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anchieta Júnior
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.0'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '3.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.0'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '3.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: bundler
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +44,14 @@ dependencies:
|
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
47
|
+
version: 12.3.3
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
54
|
+
version: 12.3.3
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: rspec
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,7 +104,6 @@ files:
|
|
110
104
|
- ".github/workflows/ci.yml"
|
111
105
|
- ".gitignore"
|
112
106
|
- ".rspec"
|
113
|
-
- ".travis.yml"
|
114
107
|
- Gemfile
|
115
108
|
- Gemfile.lock
|
116
109
|
- LICENSE.txt
|
@@ -130,7 +123,7 @@ metadata:
|
|
130
123
|
homepage_uri: https://github.com/anchietajunior.com/acw
|
131
124
|
source_code_uri: https://github.com/anchietajunior/acw
|
132
125
|
changelog_uri: https://github.com/anchietajunior/acw
|
133
|
-
post_install_message:
|
126
|
+
post_install_message:
|
134
127
|
rdoc_options: []
|
135
128
|
require_paths:
|
136
129
|
- lib
|
@@ -145,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
138
|
- !ruby/object:Gem::Version
|
146
139
|
version: '0'
|
147
140
|
requirements: []
|
148
|
-
rubygems_version: 3.0.
|
149
|
-
signing_key:
|
141
|
+
rubygems_version: 3.0.8
|
142
|
+
signing_key:
|
150
143
|
specification_version: 4
|
151
144
|
summary: Active Campaign Wrapper.
|
152
145
|
test_files: []
|