nimble-api 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -6
- data/lib/nimble/contact.rb +9 -0
- data/lib/nimble/contacts.rb +2 -0
- data/lib/nimble/version.rb +1 -1
- data/nimble-api-0.1.gem +0 -0
- data/nimble_api.gemspec +1 -1
- data/spec/integration/contacts_spec.rb +14 -2
- data/spec/spec_helper.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb4a1b6010b3d5abb6ecbcfac6d900abbe61bc39
|
4
|
+
data.tar.gz: 8f5bdc7cb2f8543b59a822221eb1b42861df1945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10a098e868490ba7fdabc74371ff229b374500a4cc76c4fe857a24c50ef42352c8e9429ff4557cb1e550eb8e0976def6584f0d61d80acf3984ff5076a9173488
|
7
|
+
data.tar.gz: fe718853e8cb0cdf0108b7364090ff91d247e6e5f9a45e65e74b9ca4a5095795a0edfb08aa1527f24a7327aad7feb737b4a245044ad639f73aad66a892c5863a
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ References:
|
|
12
12
|
|
13
13
|
The nimble api uses oauth for authorization. As such, you are required to obtain a client secret, token and registered callback url for each domain (including your localhost for testing) before starting to use this wrapper. Once you have obtained these keys, you will need to generate a refresh token. This allows you to access the API without needing to do the oauth dance to recreate your api client each time.
|
14
14
|
|
15
|
-
To use this wrapper, configure the
|
15
|
+
To use this wrapper, configure the NimbleApi with the following:
|
16
16
|
|
17
17
|
NimbleApi.configure do |c|
|
18
18
|
c.client_id = ENV['CLIENT_ID']
|
@@ -24,11 +24,13 @@ If you plan to use this with rails, create config/initializers/nimble.rb with th
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
+
> require 'nimble-api'
|
28
|
+
|
27
29
|
# Configure with your id, secret and refresh token for your application
|
28
30
|
NimbleApi.configure do |c|
|
29
|
-
c.client_id = ENV['
|
30
|
-
c.client_secret = ENV['
|
31
|
-
c.refresh_token = ENV['
|
31
|
+
c.client_id = ENV['NIMBLE_CLIENT_ID']
|
32
|
+
c.client_secret = ENV['NIMBLE_CLIENT_SECRET']
|
33
|
+
c.refresh_token = ENV['NIMBLE_REFRESH_TOKEN']
|
32
34
|
end
|
33
35
|
|
34
36
|
# Create a nimble object
|
@@ -47,6 +49,10 @@ If you plan to use this with rails, create config/initializers/nimble.rb with th
|
|
47
49
|
|
48
50
|
fred.save
|
49
51
|
|
52
|
+
# Attempt to save duplicate person throws error - checking is based on first email value
|
53
|
+
> fred.save
|
54
|
+
RuntimeError: fred@bedrock.org already exists!
|
55
|
+
|
50
56
|
# Update one element, or multiple
|
51
57
|
fred.update("parent company" => [{ "modifier"=>"","value"=>"Cogswell Cogs"}])
|
52
58
|
|
@@ -80,11 +86,14 @@ If you plan to use this with rails, create config/initializers/nimble.rb with th
|
|
80
86
|
> @nimble.contacts.list
|
81
87
|
=> {"meta"=>{"per_page"=>30, "total"=>238, "pages"=>8, "page"=>1}, "resources"=>[...]
|
82
88
|
|
83
|
-
|
89
|
+
> @nimble.contacts.list(fields: ['first name', 'last name', 'email'])
|
84
90
|
=> ... limited to just these fields
|
85
91
|
|
86
|
-
|
92
|
+
> @nimble.contacts.list(keyword: 'fred')
|
87
93
|
=> {"meta"=>{"per_page"=>30, "total"=>1, "pages"=>1, "page"=>1}, "resources"=>[ ... just one ... ]
|
94
|
+
|
95
|
+
> @nimble.contacts.list_ids( per_page:100, page: 2 )
|
96
|
+
=> {"meta"=>{"per_page"=>100, "total"=>396, "pages"=>4, "page"=>2}, "resources"=>[ ... 100 resources ... ]
|
88
97
|
|
89
98
|
## Contacts
|
90
99
|
|
data/lib/nimble/contact.rb
CHANGED
@@ -58,6 +58,7 @@ module NimbleApi
|
|
58
58
|
self
|
59
59
|
end
|
60
60
|
|
61
|
+
# Searches contacts for matching email, sets self.contact to matching result
|
61
62
|
def by_email email
|
62
63
|
query = { "and" => [{ "email" => { "is"=> email } },{ "record type"=> { "is"=> "person" }} ] }
|
63
64
|
resp = @nimble.get 'contacts', { :query => query.to_json }
|
@@ -66,6 +67,7 @@ module NimbleApi
|
|
66
67
|
self
|
67
68
|
end
|
68
69
|
|
70
|
+
# Gets contact by id and sets self.contact to result
|
69
71
|
def fetch id=nil
|
70
72
|
id ||= self.id
|
71
73
|
resp = @nimble.get "contact/#{id}"
|
@@ -75,16 +77,19 @@ module NimbleApi
|
|
75
77
|
end
|
76
78
|
alias_method :get, :fetch
|
77
79
|
|
80
|
+
# Update with param 'fields' set to passed in param hash
|
78
81
|
def update fields
|
79
82
|
self.contact = @nimble.put "contact/#{self.id}", { fields: fields }
|
80
83
|
return nil unless self.contact
|
81
84
|
self
|
82
85
|
end
|
83
86
|
|
87
|
+
# Returns notes for contact, based on params if provided
|
84
88
|
def notes params=nil
|
85
89
|
@nimble.get "contact/#{self.id}/notes", params
|
86
90
|
end
|
87
91
|
|
92
|
+
# Adds note to contact. Preview set to 64 chars substring or can be provided
|
88
93
|
def note note, preview=nil
|
89
94
|
preview ||= note[0..64]
|
90
95
|
params = {
|
@@ -95,15 +100,19 @@ module NimbleApi
|
|
95
100
|
@nimble.post "contacts/notes", params
|
96
101
|
end
|
97
102
|
|
103
|
+
# Delete not by id for self.contact
|
98
104
|
def delete_note id
|
99
105
|
@nimble.delete "contact/notes/#{id}"
|
100
106
|
end
|
101
107
|
|
108
|
+
# Delete contact with id of self.contact, or by id as argument
|
102
109
|
def delete id=nil
|
103
110
|
id ||= self.id
|
104
111
|
@nimble.delete "contact/#{id}"
|
105
112
|
end
|
106
113
|
|
114
|
+
# Create new task for contac. due_date argument is parsed by Chronic and can be of
|
115
|
+
# format 'next week', 'tomorrow', 'Friday', 'Oct 10, 2014', etc.
|
107
116
|
def task due_date, subject, notes=nil
|
108
117
|
due = Chronic.parse(due_date).strftime('%Y-%m-%d %H:%M')
|
109
118
|
params = {
|
data/lib/nimble/contacts.rb
CHANGED
@@ -6,12 +6,14 @@ module NimbleApi
|
|
6
6
|
@nimble = nimble
|
7
7
|
end
|
8
8
|
|
9
|
+
# Returns list of contacts. Limits contacts and fields with params if provided
|
9
10
|
def list params={}
|
10
11
|
params[:fields] = params[:fields].join(',') if params[:fields]
|
11
12
|
params[:record_type] ||= 'person'
|
12
13
|
@nimble.get "contacts", params
|
13
14
|
end
|
14
15
|
|
16
|
+
# Returns list of contacts ids only. Limits contacts with params if provided
|
15
17
|
def list_ids params={}
|
16
18
|
@nimble.get "contacts/ids", params
|
17
19
|
end
|
data/lib/nimble/version.rb
CHANGED
data/nimble-api-0.1.gem
ADDED
Binary file
|
data/nimble_api.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency "rspec", "~> 2.14"
|
33
33
|
spec.add_development_dependency "rake", "~> 10.1"
|
34
34
|
|
35
|
-
spec.add_dependency "faraday", "~> 0.
|
35
|
+
spec.add_dependency "faraday", "~> 0.8"
|
36
36
|
spec.add_dependency "chronic", "~> 0.10"
|
37
37
|
spec.add_dependency "json", "~> 1.7"
|
38
38
|
|
@@ -9,6 +9,18 @@ describe NimbleApi::Contacts do
|
|
9
9
|
c.refresh_token = REFRESH_TOKEN
|
10
10
|
end
|
11
11
|
@nimble = NimbleApi()
|
12
|
+
@fred = @nimble.contact.by_email 'fred@bedrock.org'
|
13
|
+
unless @fred
|
14
|
+
@person = {
|
15
|
+
'first name' => 'Fred',
|
16
|
+
'last name' => 'Flintstone',
|
17
|
+
'email' => 'fred@bedrock.org',
|
18
|
+
'tags' => 'test'
|
19
|
+
}
|
20
|
+
@fred = @nimble.contact.create @person
|
21
|
+
@fred.save
|
22
|
+
end
|
23
|
+
|
12
24
|
end
|
13
25
|
|
14
26
|
describe "list" do
|
@@ -33,8 +45,8 @@ describe NimbleApi::Contacts do
|
|
33
45
|
end
|
34
46
|
|
35
47
|
it "supports keyword param" do
|
36
|
-
resp = @nimble.contacts.list(keyword: '
|
37
|
-
resp['resources'][0]['fields']['first name'][0]['value'].should eq '
|
48
|
+
resp = @nimble.contacts.list(keyword: 'Fred')
|
49
|
+
resp['resources'][0]['fields']['first name'][0]['value'].should eq 'Fred'
|
38
50
|
end
|
39
51
|
end
|
40
52
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nimble-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Wilkerson
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.8'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.8'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: chronic
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/nimble/contact.rb
|
109
109
|
- lib/nimble/contacts.rb
|
110
110
|
- lib/nimble/version.rb
|
111
|
+
- nimble-api-0.1.gem
|
111
112
|
- nimble_api.gemspec
|
112
113
|
- spec/integration/contact_spec.rb
|
113
114
|
- spec/integration/contacts_spec.rb
|
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
138
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.4.2
|
139
140
|
signing_key:
|
140
141
|
specification_version: 4
|
141
142
|
summary: Nimble CRM Api Wrapper
|