get_response_api 0.1.0 → 0.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 +4 -4
- data/lib/get_response_api/client.rb +3 -10
- data/lib/get_response_api/connection.rb +17 -13
- data/lib/get_response_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa37f0f5319a44641fc9753cd64a11d78a644a8b
|
4
|
+
data.tar.gz: 44364fa431a21a1e440484551b3563e437e6a651
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88e2c3d7a0f44a0cdfa8688ef9eccd540941049bfeb3e0214e4d1c895098188da713348e65891ba9046eebc3af57b9c2289770db4381c2553329b3584aa9f096
|
7
|
+
data.tar.gz: 8ac94955e7bcf569978c4288265a7c130e2633e9325dd5fa91c3807d2e33fa3547d8a2939377613ffa8ea010ea4bb5e03da9326ec23952e43d76bb73fc032284
|
@@ -5,18 +5,11 @@ module GetResponseApi
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def account
|
8
|
-
|
9
|
-
|
10
|
-
if error?(response) && response['message']
|
11
|
-
return response['message']
|
12
|
-
end
|
13
|
-
response
|
8
|
+
@connection.request(:get, '/accounts')
|
14
9
|
end
|
15
10
|
|
16
|
-
|
17
|
-
|
18
|
-
def error?(response)
|
19
|
-
response['httpStatus']
|
11
|
+
def campaigns
|
12
|
+
@connection.request(:get, '/campaigns')
|
20
13
|
end
|
21
14
|
end
|
22
15
|
end
|
@@ -2,26 +2,28 @@ require 'httparty'
|
|
2
2
|
|
3
3
|
module GetResponseApi
|
4
4
|
class Connection
|
5
|
-
API_ENDPOINT = 'https://api.getresponse.com/v3'
|
5
|
+
API_ENDPOINT = 'https://api.getresponse.com/v3'.freeze
|
6
6
|
TIMEOUT = 7
|
7
7
|
|
8
8
|
def initialize(api_key)
|
9
9
|
@api_key = api_key
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
)
|
12
|
+
def request(method, path)
|
13
|
+
response = http_request(method, path).parsed_response
|
14
|
+
|
15
|
+
if error?(response) && response['message']
|
16
|
+
return response['message']
|
17
|
+
end
|
18
|
+
response
|
20
19
|
end
|
21
20
|
|
22
|
-
|
21
|
+
private
|
22
|
+
|
23
|
+
def http_request(request, path, body: {}, headers: {})
|
23
24
|
headers.merge!(auth)
|
24
|
-
HTTParty.
|
25
|
+
HTTParty.public_send(
|
26
|
+
request,
|
25
27
|
"#{API_ENDPOINT}#{path}",
|
26
28
|
body: body.to_json,
|
27
29
|
headers: headers,
|
@@ -29,13 +31,15 @@ module GetResponseApi
|
|
29
31
|
)
|
30
32
|
end
|
31
33
|
|
32
|
-
private
|
33
|
-
|
34
34
|
def auth
|
35
35
|
{
|
36
36
|
'X-Auth-Token' => "api-key #{@api_key}",
|
37
37
|
'Content-Type' => 'application/json'
|
38
38
|
}
|
39
39
|
end
|
40
|
+
|
41
|
+
def error?(response)
|
42
|
+
response.is_a?(Hash) && response['httpStatus']
|
43
|
+
end
|
40
44
|
end
|
41
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: get_response_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juliane Lima
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|