nimble-api 0.1.1 → 0.1.2
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/README.md +4 -1
- data/lib/nimble/contact.rb +9 -0
- data/lib/nimble/version.rb +1 -1
- data/nimble-api-0.1.1.gem +0 -0
- data/nimble_api.gemspec +1 -0
- data/spec/integration/contact_spec.rb +5 -1
- data/spec/spec_helper.rb +1 -1
- metadata +16 -2
- data/nimble-api-0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54f10312d03936e9b26443dbe9caec3bd4d03f8c
|
4
|
+
data.tar.gz: 42fc59c4e51ad59b292db6e10dad6563ffd46a7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ffcbe0548434a00ecfa3f61dad00290611d728a84be1b70c9b9afb4c3f26d43f29956b24d1fe33a495a27ac07d11c78a7543be063153140eb30c960398aa26
|
7
|
+
data.tar.gz: 00cdba8f5b1e1f9e8665db4c73afc31976539e7d39a3618306e84a1a1c4aed19491dff367abbd114f0fed173047042eb683c397de9a81ca05c874e16d94422ea
|
data/README.md
CHANGED
@@ -56,12 +56,15 @@ If you plan to use this with rails, create config/initializers/nimble.rb with th
|
|
56
56
|
# Update one element, or multiple
|
57
57
|
fred.update("parent company" => [{ "modifier"=>"","value"=>"Cogswell Cogs"}])
|
58
58
|
|
59
|
-
# Find a contact by their email address
|
59
|
+
# Find a contact by their email address, best way to find a unique user
|
60
60
|
fred = @nimble.contact.by_email 'fred@bedrock.org'
|
61
61
|
|
62
62
|
# Find a contact by id
|
63
63
|
fred = @nimble.contact.fetch "54444842faed29141e5c7300"
|
64
64
|
|
65
|
+
# Find a contact by their first and last name, returns the first match - be careful!
|
66
|
+
fred = @nimble.contact.by_name 'Fred', 'Flintstone'
|
67
|
+
|
65
68
|
# Use convenience methods to display the id, email and fields
|
66
69
|
> fred.id
|
67
70
|
=> "54444842faed29141e5c7300"
|
data/lib/nimble/contact.rb
CHANGED
@@ -67,6 +67,15 @@ module NimbleApi
|
|
67
67
|
self
|
68
68
|
end
|
69
69
|
|
70
|
+
# Searches contacts for matching name, sets self.contact to first matching result
|
71
|
+
def by_name first_name, last_name
|
72
|
+
query = { "and" => [{ "first name" => { "is"=> first_name } }, { "last name" => { "is"=> last_name } }, { "record type"=> { "is"=> "person" }} ] }
|
73
|
+
resp = @nimble.get 'contacts', { :query => query.to_json }
|
74
|
+
self.contact = resp['resources'].first
|
75
|
+
return nil unless self.contact
|
76
|
+
self
|
77
|
+
end
|
78
|
+
|
70
79
|
# Gets contact by id and sets self.contact to result
|
71
80
|
def fetch id=nil
|
72
81
|
id ||= self.id
|
data/lib/nimble/version.rb
CHANGED
Binary file
|
data/nimble_api.gemspec
CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "bundler", "~> 1.3"
|
32
32
|
spec.add_development_dependency "rspec", "~> 2.14"
|
33
33
|
spec.add_development_dependency "rake", "~> 10.1"
|
34
|
+
spec.add_development_dependency "pry"
|
34
35
|
|
35
36
|
spec.add_dependency "faraday", "~> 0.8"
|
36
37
|
spec.add_dependency "chronic", "~> 0.10"
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
2
|
describe NimbleApi::Contact do
|
4
3
|
|
5
4
|
before :each do
|
@@ -58,6 +57,11 @@ describe NimbleApi::Contact do
|
|
58
57
|
resp.should_not be_nil
|
59
58
|
end
|
60
59
|
|
60
|
+
it "can find contact by_name" do
|
61
|
+
fred = @nimble.contact.by_name 'Fred', 'Flintstone'
|
62
|
+
fred.fields['last name'][0]['value'].should eq 'Flintstone'
|
63
|
+
end
|
64
|
+
|
61
65
|
it "returns contact by id" do
|
62
66
|
found = @nimble.contact.fetch @fred.id
|
63
67
|
found.should_not be_nil
|
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: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Wilkerson
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: faraday
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +122,7 @@ files:
|
|
108
122
|
- lib/nimble/contact.rb
|
109
123
|
- lib/nimble/contacts.rb
|
110
124
|
- lib/nimble/version.rb
|
111
|
-
- nimble-api-0.1.gem
|
125
|
+
- nimble-api-0.1.1.gem
|
112
126
|
- nimble_api.gemspec
|
113
127
|
- spec/integration/contact_spec.rb
|
114
128
|
- spec/integration/contacts_spec.rb
|
data/nimble-api-0.1.gem
DELETED
Binary file
|