contactually-api 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/contactually/api.rb +26 -22
- data/lib/contactually/middleware/error_detector.rb +1 -1
- data/lib/contactually/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: 52c58a5aa6d6ecc6d612f0ae0366a5bce859ccf0
|
4
|
+
data.tar.gz: 7c71f707ba29bb435b89f90601ac38345be21d19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 879d68b4a16df5ded12212deb10abe89e79f27b11e0f1c219ff8b8625b631d064c7522ab3584c1cbf3cb95abc83f4b265a876eaffbadeb80be5c81b61689c593
|
7
|
+
data.tar.gz: cf5a164d0ba56c6605150e21a00c64afdeea94d116c6de467e4b4636d7fb8da8d6238833176534598d3f113ca80948ae1791de2555711f003b976da65f2f11b6
|
data/lib/contactually/api.rb
CHANGED
@@ -6,65 +6,69 @@ module Contactually
|
|
6
6
|
@base_url = Contactually.config.contactually_url
|
7
7
|
end
|
8
8
|
|
9
|
-
def call(url,
|
10
|
-
response = send(
|
9
|
+
def call(url, http_method, params={})
|
10
|
+
response = send(http_method, url, params)
|
11
11
|
JSON.load(response.body)
|
12
12
|
end
|
13
13
|
|
14
14
|
def contacts
|
15
|
-
Contactually::Contacts.new self
|
15
|
+
@contacts ||= Contactually::Contacts.new self
|
16
16
|
end
|
17
17
|
|
18
18
|
def notes
|
19
|
-
Contactually::Notes.new self
|
19
|
+
@notes ||= Contactually::Notes.new self
|
20
20
|
end
|
21
21
|
|
22
22
|
def groupings
|
23
|
-
Contactually::Groupings.new self
|
23
|
+
@groupings ||= Contactually::Groupings.new self
|
24
24
|
end
|
25
25
|
|
26
26
|
def accounts
|
27
|
-
Contactually::Accounts.new self
|
27
|
+
@accounts ||= Contactually::Accounts.new self
|
28
28
|
end
|
29
29
|
|
30
30
|
def contact_groupings
|
31
|
-
Contactually::ContactGroupings.new self
|
31
|
+
@contact_groupings ||= Contactually::ContactGroupings.new self
|
32
32
|
end
|
33
33
|
|
34
34
|
def connection
|
35
35
|
@connection ||= Faraday.new do |faraday|
|
36
|
-
faraday.adapter
|
36
|
+
faraday.adapter Faraday.default_adapter
|
37
37
|
faraday.headers['Content-Type'] = 'application/json'
|
38
38
|
faraday.use Contactually::Middleware::ErrorDetector
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
private
|
43
43
|
|
44
44
|
def call_params(params)
|
45
45
|
params.merge({ api_key: @api_key })
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
req.body = call_params(params).to_json
|
53
|
-
end
|
54
|
-
response
|
48
|
+
def post(url, params)
|
49
|
+
connection.post do |req|
|
50
|
+
req.url base_url(url)
|
51
|
+
req.body = call_params(params).to_json
|
55
52
|
end
|
56
53
|
end
|
57
54
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
55
|
+
def put(url, params)
|
56
|
+
connection.put do |req|
|
57
|
+
req.url base_url(url)
|
58
|
+
req.body = call_params(params).to_json
|
62
59
|
end
|
63
60
|
end
|
64
61
|
|
65
|
-
def
|
66
|
-
|
62
|
+
def get(url, params)
|
63
|
+
connection.get(base_url(url), call_params(params))
|
64
|
+
end
|
65
|
+
|
66
|
+
def delete(url, params)
|
67
|
+
connection.delete(base_url(url), call_params(params))
|
67
68
|
end
|
68
69
|
|
70
|
+
def base_url(url)
|
71
|
+
"#{@base_url}#{url}"
|
69
72
|
end
|
73
|
+
end
|
70
74
|
end
|
data/lib/contactually/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contactually-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Heck
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|