contactually-api 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: ee398da691add3f2fe14f48f1bfe6df4fd8ccc03
4
- data.tar.gz: 07a3ad39c3145dd57d8ea38157de6a2a5f28c18f
3
+ metadata.gz: 52c58a5aa6d6ecc6d612f0ae0366a5bce859ccf0
4
+ data.tar.gz: 7c71f707ba29bb435b89f90601ac38345be21d19
5
5
  SHA512:
6
- metadata.gz: 954b718ce25a9ced2f79a4f9763368d1a6c86630ca0bb0f0aa52f45734d65e31547fc7158c122eba2ea92932ad465b1f4fc024dae7ffb9ef26aaf054fe5f4359
7
- data.tar.gz: 57c10868f0545d74c9964713552388dfccef93408ed5bbb480340d9b49b85dbd6672762af1712ad390344d978b2b9b359885107c1d53d8dba4e8df348a4cf078
6
+ metadata.gz: 879d68b4a16df5ded12212deb10abe89e79f27b11e0f1c219ff8b8625b631d064c7522ab3584c1cbf3cb95abc83f4b265a876eaffbadeb80be5c81b61689c593
7
+ data.tar.gz: cf5a164d0ba56c6605150e21a00c64afdeea94d116c6de467e4b4636d7fb8da8d6238833176534598d3f113ca80948ae1791de2555711f003b976da65f2f11b6
@@ -6,65 +6,69 @@ module Contactually
6
6
  @base_url = Contactually.config.contactually_url
7
7
  end
8
8
 
9
- def call(url, method, params={})
10
- response = send(method, url, params)
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 Faraday.default_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
- private
42
+ private
43
43
 
44
44
  def call_params(params)
45
45
  params.merge({ api_key: @api_key })
46
46
  end
47
47
 
48
- [ :post, :put ].each do |method_name|
49
- define_method(method_name) do |url, params|
50
- response = connection.send(method_name) do |req|
51
- req.url base_url(url)
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
- [ :get, :delete ].each do |method_name|
59
- define_method(method_name) do |url, params|
60
- response = connection.send(method_name, base_url(url), call_params(params))
61
- response
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 base_url(url)
66
- "#{@base_url}#{url}"
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
@@ -10,7 +10,7 @@ module Contactually
10
10
  end
11
11
  end
12
12
 
13
- private
13
+ private
14
14
 
15
15
  def cast_error(body)
16
16
  case JSON.parse(body)['error']
@@ -1,3 +1,3 @@
1
1
  module Contactually
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-09 00:00:00.000000000 Z
11
+ date: 2014-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport