contactually 0.0.3 → 0.0.4
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/contactually/version.rb +1 -1
- data/lib/contactually.rb +15 -2
- 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: 48c659debeddaa05a2693dfed4014feaf8cb600d
|
4
|
+
data.tar.gz: 435cae2af1c168709ead2ded43c98f50deffb1a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1850c19b622ed5b3ad346883de6486db01be17efb76d40766ced7e1a5d32a1927b7e7150c7c1fd5bb673c9378a12fcb32427398ca91a201414055b0d49badca0
|
7
|
+
data.tar.gz: 87a78219cba198cf9afc4431cf12e289df50f24b056bdb2b3c6858d670ef97ea3995929179394d0e02e3ed7798671fcecf7f7fb91c20c6daed5d047e72be40d8
|
data/lib/contactually/version.rb
CHANGED
data/lib/contactually.rb
CHANGED
@@ -4,6 +4,8 @@ require "json"
|
|
4
4
|
module Contactually
|
5
5
|
class API
|
6
6
|
|
7
|
+
ReturnValue = Struct.new(:code, :body)
|
8
|
+
|
7
9
|
HTTP_ACTIONS = %w(get post put delete).freeze
|
8
10
|
METHODS = %w(contacts notes groupings).freeze
|
9
11
|
|
@@ -43,7 +45,9 @@ module Contactually
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def make_call(composite, params = {})
|
46
|
-
|
48
|
+
unless get_methods(composite)
|
49
|
+
return ReturnValue.new(400, "Bad action/method '#{composite}'")
|
50
|
+
end
|
47
51
|
uri = build_uri(contactually_method, params)
|
48
52
|
response = Curl.send(http_action.to_sym, uri, param_fields(params)) do |curl|
|
49
53
|
@headers.each do |header_name, header_value|
|
@@ -52,7 +56,16 @@ module Contactually
|
|
52
56
|
curl.headers['Accept'] = 'application/json'
|
53
57
|
curl.headers['Content-Type'] = 'application/json'
|
54
58
|
end
|
55
|
-
|
59
|
+
|
60
|
+
if [200, 201, 202].include?(response.response_code)
|
61
|
+
return ReturnValue.new(
|
62
|
+
response.response_code,
|
63
|
+
JSON.load("[#{response.body_str}]").first
|
64
|
+
)
|
65
|
+
end
|
66
|
+
ReturnValue.new(response.response_code, response.body_str)
|
67
|
+
rescue => e
|
68
|
+
ReturnValue.new(500, "Could not complete call, #{e.message}")
|
56
69
|
end
|
57
70
|
|
58
71
|
def build_uri(contactually_method, args = {})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contactually
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guille Carlos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write a gem description
|
14
14
|
email:
|