leadcli 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +2 -2
- data/lib/leadcli/api_caller.rb +3 -3
- data/lib/leadcli/configuration.rb +1 -1
- data/lib/leadcli/lead.rb +2 -2
- data/lib/leadcli/routes.rb +2 -2
- data/lib/leadcli/version.rb +1 -1
- data/spec/leadcli/api_call_spec.rb +2 -2
- data/spec/leadcli/api_caller_spec.rb +5 -5
- data/spec/leadcli/lead_spec.rb +2 -2
- data/spec/leadcli/routes_spec.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf2ab2d5fdb3f54a619d1a4d9bd5879b4d239059
|
4
|
+
data.tar.gz: db9b27a4fbe3908e2b0aa1a39a1c3d7d90bfdc64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71f97680c76f397e0112aff0131d988f196f82f9947a6922934fe6c95c5d49b65c59c5b46c6d1025b475c2ec8d76fd14474feae1d287040ccea2d6270c5aefa0
|
7
|
+
data.tar.gz: e06f39a1833fe2435b918fc264c5fa9a8d8ed0bd6dab2d7c968d09ae70069f0712964d8191357f0fc4cf51d568e6214f2b38eb78f1663feb6ed213f4fef510e9
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
leadcli (0.0.
|
4
|
+
leadcli (0.0.4)
|
5
5
|
rest-client
|
6
6
|
|
7
7
|
GEM
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
fakeweb (1.3.0)
|
14
14
|
http-cookie (1.0.2)
|
15
15
|
domain_name (~> 0.5)
|
16
|
-
mime-types (2.6.
|
16
|
+
mime-types (2.6.2)
|
17
17
|
netrc (0.10.3)
|
18
18
|
rest-client (1.8.0)
|
19
19
|
http-cookie (>= 1.0.2, < 2.0)
|
data/lib/leadcli/api_caller.rb
CHANGED
@@ -53,9 +53,9 @@ module Leadcli
|
|
53
53
|
:accept => :json
|
54
54
|
}
|
55
55
|
parameters = {
|
56
|
-
url
|
57
|
-
method
|
58
|
-
headers
|
56
|
+
:url => url,
|
57
|
+
:method => method,
|
58
|
+
:headers => headers
|
59
59
|
}
|
60
60
|
parameters[:payload] = options[:payload] if method == :post or method == :put
|
61
61
|
RestClient::Request.execute(parameters)
|
data/lib/leadcli/lead.rb
CHANGED
@@ -11,11 +11,11 @@ module Leadcli
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def create(params)
|
14
|
-
api_call :create, url_options
|
14
|
+
api_call :create, :url_options => {}, :payload => { :lead => params }, :failure => :handle_failure, :success => :handle_success
|
15
15
|
end
|
16
16
|
|
17
17
|
def delete(lead_id)
|
18
|
-
api_call :delete, url_options
|
18
|
+
api_call :delete, :url_options => { :id => lead_id }, :failure => :handle_failure, :success => :handle_success
|
19
19
|
end
|
20
20
|
|
21
21
|
def handle_failure(response)
|
data/lib/leadcli/routes.rb
CHANGED
@@ -6,7 +6,7 @@ module Leadcli
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def create_url(options={})
|
9
|
-
url = http_scheme.build(base_options.merge(path
|
9
|
+
url = http_scheme.build(base_options.merge(:path => create_path))
|
10
10
|
url.query = options[:query].map { |k,v| "#{k}=#{v}" }.join('&') if options[:query]
|
11
11
|
url.to_s
|
12
12
|
end
|
@@ -16,7 +16,7 @@ module Leadcli
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def delete_url(options)
|
19
|
-
url = http_scheme.build(base_options.merge(path
|
19
|
+
url = http_scheme.build(base_options.merge(:path => delete_path(options[:id])))
|
20
20
|
url.to_s
|
21
21
|
end
|
22
22
|
|
data/lib/leadcli/version.rb
CHANGED
@@ -10,8 +10,8 @@ describe Leadcli::ApiCall do
|
|
10
10
|
api_call_test = ApiCallerTest.new
|
11
11
|
api_call = double('api_call')
|
12
12
|
expect(api_call).to receive(:call).with(api_call_test)
|
13
|
-
expect(Leadcli::ApiCaller).to receive(:new).with(:endpoint, { foo
|
14
|
-
api_call_test.api_call(:endpoint, { foo
|
13
|
+
expect(Leadcli::ApiCaller).to receive(:new).with(:endpoint, { :foo => :bar }).and_return(api_call)
|
14
|
+
api_call_test.api_call(:endpoint, { :foo => :bar })
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -5,9 +5,9 @@ describe Leadcli::ApiCaller do
|
|
5
5
|
|
6
6
|
describe "#new" do
|
7
7
|
it "stores the endpoint and options" do
|
8
|
-
api_caller = Leadcli::ApiCaller.new(:myendpoint, foo
|
8
|
+
api_caller = Leadcli::ApiCaller.new(:myendpoint, :foo => :bar)
|
9
9
|
expect(api_caller.endpoint).to eq(:myendpoint)
|
10
|
-
expect(api_caller.options).to eq({ foo
|
10
|
+
expect(api_caller.options).to eq({ :foo => :bar })
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -19,15 +19,15 @@ describe Leadcli::ApiCaller do
|
|
19
19
|
api_caller.call(self)
|
20
20
|
end
|
21
21
|
it "passes through any url options" do
|
22
|
-
expect(api_caller).to receive(:test_endpoint).with({ query
|
23
|
-
api_caller.options[:url_options] = { query
|
22
|
+
expect(api_caller).to receive(:test_endpoint).with({ :query => { :updated_at => '2013-07-19', :foo => :bar }}).and_return([:get, url])
|
23
|
+
api_caller.options[:url_options] = { :query => { :updated_at => '2013-07-19', :foo => :bar } }
|
24
24
|
expect(RestClient::Request).to receive(:execute).and_return(double('response', :code => 200))
|
25
25
|
api_caller.call(self)
|
26
26
|
end
|
27
27
|
describe "a GET request" do
|
28
28
|
it "make the call to the api" do
|
29
29
|
expect(api_caller).to receive(:test_endpoint).and_return([:get, url])
|
30
|
-
expect(RestClient::Request).to receive(:execute).with(hash_including(url: url, method
|
30
|
+
expect(RestClient::Request).to receive(:execute).with(hash_including(url: url, :method => :get)).and_return(double('response', :code => 200))
|
31
31
|
api_caller.call(self)
|
32
32
|
end
|
33
33
|
end
|
data/spec/leadcli/lead_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe Leadcli::Lead do
|
|
7
7
|
|
8
8
|
describe "#create" do
|
9
9
|
it "creates it" do
|
10
|
-
with_configuration(host
|
10
|
+
with_configuration(:host => HOST, :port => 3000, :token => TOKEN) do
|
11
11
|
lead.create(params)
|
12
12
|
expect(lead.last_response).to match(/Contact/)
|
13
13
|
end
|
@@ -21,7 +21,7 @@ describe Leadcli::Lead do
|
|
21
21
|
describe "#delete" do
|
22
22
|
context "when remote lead exists" do
|
23
23
|
it "delete it" do
|
24
|
-
with_configuration(host
|
24
|
+
with_configuration(:host => HOST, :port => 3000, :token => TOKEN) do
|
25
25
|
lead.create(params)
|
26
26
|
created_lead_id = JSON.parse(lead.last_response)['id']
|
27
27
|
lead.delete(created_lead_id)
|
data/spec/leadcli/routes_spec.rb
CHANGED
@@ -6,11 +6,11 @@ end
|
|
6
6
|
|
7
7
|
describe Leadcli::Routes do
|
8
8
|
let!(:test_route) { TestRoute.new }
|
9
|
-
let(:config) { { host
|
9
|
+
let(:config) { { :host => 'test.host', :port => 1234 } }
|
10
10
|
|
11
11
|
describe "create_endpoint" do
|
12
12
|
it "returns :post and the create url" do
|
13
|
-
options = { foo
|
13
|
+
options = { :foo => :bar }
|
14
14
|
expect(test_route).to receive(:create_url).with(options).and_return('my_create_url')
|
15
15
|
expect(test_route.create_endpoint(options)).to eq([:post, 'my_create_url'])
|
16
16
|
end
|
@@ -24,7 +24,7 @@ describe Leadcli::Routes do
|
|
24
24
|
end
|
25
25
|
it "adds query parameters on to the url" do
|
26
26
|
with_configuration(config) do
|
27
|
-
url = test_route.create_url(query
|
27
|
+
url = test_route.create_url(:query => { :updated_at => '2013-07-19', :foo => :bar })
|
28
28
|
expect(url).to match(/\?.*updated_at=2013-07-19/)
|
29
29
|
expect(url).to match(/\?.*foo=bar/)
|
30
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leadcli
|
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
|
- Franck D'agostini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -59,6 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".gitignore"
|
62
63
|
- Gemfile
|
63
64
|
- Gemfile.lock
|
64
65
|
- LICENSE.txt
|