nimble-api 0.1.2 → 0.1.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: 54f10312d03936e9b26443dbe9caec3bd4d03f8c
4
- data.tar.gz: 42fc59c4e51ad59b292db6e10dad6563ffd46a7d
3
+ metadata.gz: 967e3d8c708b3aee8050f90065581f121b9fcfee
4
+ data.tar.gz: b471b8fb0c989550c01243c4d261d9331c0951b0
5
5
  SHA512:
6
- metadata.gz: 65ffcbe0548434a00ecfa3f61dad00290611d728a84be1b70c9b9afb4c3f26d43f29956b24d1fe33a495a27ac07d11c78a7543be063153140eb30c960398aa26
7
- data.tar.gz: 00cdba8f5b1e1f9e8665db4c73afc31976539e7d39a3618306e84a1a1c4aed19491dff367abbd114f0fed173047042eb683c397de9a81ca05c874e16d94422ea
6
+ metadata.gz: cb74c422a0431790a2b851e2e738cf7ef87bf9df2078ac5805415e47585efa80d75170484f4be2ba54b6f5b7cda1af1b2c1fd2962471f634071a3a390b899e17
7
+ data.tar.gz: 00c1acf846828fc140e53b533e0a64404391483cba25a208697826172aadb76b7baef0a2e804d4977d174d4aec986cc4746842942fea87a0d1e0e41e4bb6c1b5
data/lib/nimble-api.rb CHANGED
@@ -6,6 +6,7 @@ require "nimble/version"
6
6
  require 'nimble/base'
7
7
  require 'nimble/contacts'
8
8
  require 'nimble/contact'
9
+ require 'nimble/metadata'
9
10
 
10
11
  def NimbleApi(options={})
11
12
  options[:client_id] = NimbleApi.client_id if NimbleApi.client_id
data/lib/nimble/base.rb CHANGED
@@ -30,8 +30,12 @@ module NimbleApi
30
30
  redirect_uri: NimbleApi.callback_path
31
31
  }
32
32
  resp = @conn.post '/oauth/token', params
33
+ if resp.status >= 400
34
+ raise resp.body
35
+ end
33
36
  access_token = (JSON resp.body)['access_token']
34
37
  @conn.headers = { 'Authorization' => "Bearer #{access_token}" }
38
+ @conn
35
39
  end
36
40
 
37
41
  def get endpoint, params={}
@@ -74,6 +78,10 @@ module NimbleApi
74
78
  NimbleApi::Contact.new(self)
75
79
  end
76
80
 
81
+ def metadata
82
+ NimbleApi::Metadata.new(self)
83
+ end
84
+
77
85
  end
78
86
 
79
87
 
@@ -0,0 +1,22 @@
1
+ module NimbleApi
2
+
3
+ class Metadata
4
+
5
+ def initialize(nimble)
6
+ @nimble = nimble
7
+ end
8
+
9
+ def all
10
+ @nimble.get "contacts/metadata"
11
+ end
12
+
13
+ def add_group params
14
+ @nimble.post 'contacts/metadata/groups', params
15
+ end
16
+
17
+ def add_field params
18
+ @nimble.post 'contacts/metadata/fields', params
19
+ end
20
+ end
21
+
22
+ end
@@ -1,5 +1,5 @@
1
1
  module NimbleApi
2
2
 
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
 
5
5
  end
Binary file
data/nimble_api.gemspec CHANGED
@@ -22,12 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.post_install_message = %q{
26
- ---------------------------------------------------------------
27
- Nimble CRM Api has been installed
28
- ----------------------------------------------------------------
29
- }
30
-
31
25
  spec.add_development_dependency "bundler", "~> 1.3"
32
26
  spec.add_development_dependency "rspec", "~> 2.14"
33
27
  spec.add_development_dependency "rake", "~> 10.1"
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe NimbleApi::Metadata do
4
+
5
+ before :each do
6
+ NimbleApi.configure do |c|
7
+ c.client_id = CLIENT_ID
8
+ c.client_secret = CLIENT_SECRET
9
+ c.refresh_token = REFRESH_TOKEN
10
+ end
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
+ end
24
+
25
+ it "should retrieve all metadata" do
26
+ resp = @nimble.metadata.all
27
+ resp.should_not be_empty
28
+ end
29
+
30
+ it "can create a custom group" do
31
+ resp = @nimble.metadata.add_group('type'=>'person','name'=>'taskit')
32
+ resp.should_not be_empty
33
+ # {"is_standard"=>false, "name"=>"taskit", "order"=>[], "type"=>"person", "id"=>"5447ee6dfaed29363fb17605", "label"=>"taskit"}
34
+ end
35
+
36
+ it "can add a custom field to the group" do
37
+ resp = @nimble.metadata.add_field('group_id' => "5447ee6dfaed29363fb17605", 'name' => 'projects', 'presentation' =>{'width' => '1', 'type' => 'single-line-text-box'})
38
+ resp.should_not be_empty
39
+ # => {"group"=>"taskit",
40
+ # "name"=>"projects",
41
+ # "modifier"=>"",
42
+ # "presentation"=>{"width"=>"1", "type"=>"single-line-text-box"},
43
+ # "id"=>"5447efa0ae31563ca75a4db1",
44
+ # "multiples"=>false,
45
+ # "label"=>"projects"}
46
+ end
47
+
48
+ end
@@ -13,19 +13,32 @@ describe NimbleApi::Base do
13
13
 
14
14
  it "can be called directly if the keys have been set via NimbleApi.configure" do
15
15
  NimbleApi.configure do |config|
16
- config.client_id = "qwer"
17
- config.client_secret = "1234"
18
- config.refresh_token = "qwer-1234"
16
+ config.client_id = CLIENT_ID
17
+ config.client_secret = CLIENT_SECRET
18
+ config.refresh_token = REFRESH_TOKEN
19
19
  end
20
20
  expect do
21
21
  NimbleApi()
22
22
  end.to_not raise_error
23
23
  end
24
24
 
25
- it "can be instanced with the keys as a param" do
26
- expect do
27
- NimbleApi({ :client_id => "qwer", :client_secret => "1234", :refresh_token =>"qwer-1234" })
28
- end.to_not raise_error
25
+ describe "when NimbleApi has not been configured" do
26
+
27
+ before(:each) do
28
+ NimbleApi.client_id = nil
29
+ end
30
+
31
+ it "can be instanced with the keys as a param" do
32
+ expect do
33
+ NimbleApi({ :client_id => CLIENT_ID, :client_secret => CLIENT_SECRET, :refresh_token => REFRESH_TOKEN })
34
+ end.to_not raise_error
35
+ end
36
+
37
+ it "raises error when instanced with incorrect keys" do
38
+ expect do
39
+ NimbleApi({ :client_id => "qwer", :client_secret => "1234", :refresh_token => "qwer-1234" })
40
+ end.to raise_error
41
+ end
29
42
  end
30
43
 
31
44
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nimble-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Wilkerson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-20 00:00:00.000000000 Z
11
+ date: 2014-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,20 +121,20 @@ files:
121
121
  - lib/nimble/base.rb
122
122
  - lib/nimble/contact.rb
123
123
  - lib/nimble/contacts.rb
124
+ - lib/nimble/metadata.rb
124
125
  - lib/nimble/version.rb
125
- - nimble-api-0.1.1.gem
126
+ - nimble-api-0.1.3.gem
126
127
  - nimble_api.gemspec
127
128
  - spec/integration/contact_spec.rb
128
129
  - spec/integration/contacts_spec.rb
130
+ - spec/integration/metadata_spec.rb
129
131
  - spec/spec_helper.rb
130
132
  - spec/unit/base_spec.rb
131
133
  homepage: https://github.com/aptos/NimbleApi
132
134
  licenses:
133
135
  - Apache
134
136
  metadata: {}
135
- post_install_message: "\n ---------------------------------------------------------------\n
136
- \ Nimble CRM Api has been installed\n ----------------------------------------------------------------\n
137
- \ "
137
+ post_install_message:
138
138
  rdoc_options: []
139
139
  require_paths:
140
140
  - lib
@@ -150,12 +150,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  version: '0'
151
151
  requirements: []
152
152
  rubyforge_project:
153
- rubygems_version: 2.4.2
153
+ rubygems_version: 2.0.14
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: Nimble CRM Api Wrapper
157
157
  test_files:
158
158
  - spec/integration/contact_spec.rb
159
159
  - spec/integration/contacts_spec.rb
160
+ - spec/integration/metadata_spec.rb
160
161
  - spec/spec_helper.rb
161
162
  - spec/unit/base_spec.rb
data/nimble-api-0.1.1.gem DELETED
Binary file