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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb4a1b6010b3d5abb6ecbcfac6d900abbe61bc39
4
- data.tar.gz: 8f5bdc7cb2f8543b59a822221eb1b42861df1945
3
+ metadata.gz: 54f10312d03936e9b26443dbe9caec3bd4d03f8c
4
+ data.tar.gz: 42fc59c4e51ad59b292db6e10dad6563ffd46a7d
5
5
  SHA512:
6
- metadata.gz: 10a098e868490ba7fdabc74371ff229b374500a4cc76c4fe857a24c50ef42352c8e9429ff4557cb1e550eb8e0976def6584f0d61d80acf3984ff5076a9173488
7
- data.tar.gz: fe718853e8cb0cdf0108b7364090ff91d247e6e5f9a45e65e74b9ca4a5095795a0edfb08aa1527f24a7327aad7feb737b4a245044ad639f73aad66a892c5863a
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"
@@ -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
@@ -1,5 +1,5 @@
1
1
  module NimbleApi
2
2
 
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
 
5
5
  end
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
@@ -6,8 +6,8 @@ require 'bundler/setup'
6
6
  Bundler.setup(:development)
7
7
 
8
8
  require "rspec"
9
+ require "pry"
9
10
  require "nimble-api"
10
-
11
11
  RSpec.configure do |config|
12
12
  config.expect_with :rspec do |c|
13
13
  c.syntax = [:should, :expect]
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.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