agendor-ruby 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/agendor-ruby.gemspec +4 -3
- data/lib/agendor-ruby.rb +1 -1
- data/lib/agendor/api.rb +35 -0
- data/spec/api_spec.rb +2 -2
- data/spec/cassettes/Agendor_Api/creates_a_person.yml +41 -0
- metadata +5 -3
- data/lib/api.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73ef87c6d7da05894f6161bf0a7a856edb564647
|
4
|
+
data.tar.gz: ef6fe0253aee276f606fd4b08651bfe3d0db7a99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6d3331029c4d57e11d5c77ba6ad6249efe8d2e731089d899b204d222a61dce0096402935bb460cca6e0a8e2257d77bdf2553997ad9dc6016841c6dd9a954209
|
7
|
+
data.tar.gz: faa463e781478ccf05438b9c97bf14399c11c61f7b9d319b7bb4009a7abf862ba8aeeba16c0ed8be1cece967ba5fe94a90e4633935efaea2d2939045d4a2aebb
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/agendor-ruby.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "agendor-ruby"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bruno Ghisi"]
|
12
|
-
s.date = "2014-06-
|
12
|
+
s.date = "2014-06-02"
|
13
13
|
s.description = "Agendor CRM ruby client"
|
14
14
|
s.email = "brunogh@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,8 +26,9 @@ Gem::Specification.new do |s|
|
|
26
26
|
"VERSION",
|
27
27
|
"agendor-ruby.gemspec",
|
28
28
|
"lib/agendor-ruby.rb",
|
29
|
-
"lib/api.rb",
|
29
|
+
"lib/agendor/api.rb",
|
30
30
|
"spec/api_spec.rb",
|
31
|
+
"spec/cassettes/Agendor_Api/creates_a_person.yml",
|
31
32
|
"spec/cassettes/Api/creates_a_person.yml",
|
32
33
|
"spec/spec_helper.rb"
|
33
34
|
]
|
data/lib/agendor-ruby.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require "api"
|
1
|
+
require "agendor/api"
|
2
2
|
require 'httparty'
|
data/lib/agendor/api.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Agendor
|
2
|
+
class Api
|
3
|
+
|
4
|
+
URL = "https://api.agendor.com.br/v1/people"
|
5
|
+
|
6
|
+
def initialize(username, password)
|
7
|
+
@username = username
|
8
|
+
@password = password
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_person(params)
|
12
|
+
person = {
|
13
|
+
"name" => params[:name],
|
14
|
+
"role" => params[:role],
|
15
|
+
"emails" => params[:emails_array],
|
16
|
+
"description" => params[:description]
|
17
|
+
}
|
18
|
+
post = HTTParty.post(URL, :body => person.to_json, :headers => headers, :basic_auth => auth)
|
19
|
+
code = post.response.code
|
20
|
+
raise "Response not HTTP OK: #{code}" if code != "201"
|
21
|
+
code
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def auth
|
27
|
+
{:username => @username, :password => @password}
|
28
|
+
end
|
29
|
+
|
30
|
+
def headers
|
31
|
+
{ 'Content-Type' => "application/json" }
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
data/spec/api_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Api", :vcr do
|
3
|
+
describe "Agendor::Api", :vcr do
|
4
4
|
|
5
5
|
it "creates a person" do
|
6
|
-
client = Api.new("brunogh@gmail.com", "qwe123")
|
6
|
+
client = Agendor::Api.new("brunogh@gmail.com", "qwe123")
|
7
7
|
client.add_person({:name=>"Whatever", :role=>"Singer", :description => "Nice guy", :emails_array=>["whateveremail@gmail.com"]}).should eq("201")
|
8
8
|
end
|
9
9
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://brunogh%40gmail.com:qwe123@api.agendor.com.br/v1/people
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"name":"Whatever","role":"Singer","emails":["whateveremail@gmail.com"],"description":"Nice
|
9
|
+
guy"}'
|
10
|
+
headers:
|
11
|
+
content-type:
|
12
|
+
- application/json
|
13
|
+
authorization:
|
14
|
+
- Basic YnJ1bm9naEBnbWFpbC5jb206cXdlMTIz
|
15
|
+
response:
|
16
|
+
status:
|
17
|
+
code: 201
|
18
|
+
message: Created
|
19
|
+
headers:
|
20
|
+
server:
|
21
|
+
- nginx/1.4.7
|
22
|
+
date:
|
23
|
+
- Mon, 02 Jun 2014 02:21:40 GMT
|
24
|
+
content-type:
|
25
|
+
- application/json; charset=utf-8
|
26
|
+
content-length:
|
27
|
+
- '585'
|
28
|
+
connection:
|
29
|
+
- close
|
30
|
+
location:
|
31
|
+
- https://api.agendor.com.br/v1/people/514315
|
32
|
+
cache-control:
|
33
|
+
- max-age=2592000
|
34
|
+
expires:
|
35
|
+
- Wed, 02 Jul 2014 02:21:40 GMT
|
36
|
+
body:
|
37
|
+
encoding: UTF-8
|
38
|
+
string: '{"personId":514315,"customer":{"customerId":17134,"name":"Teste"},"user":{"userId":24327,"name":"Bruno"},"category":null,"organization":null,"phones":[{"number":null,"type":"work"},{"number":null,"type":"mobile"},{"number":null,"type":"fax"}],"emails":["whateveremail@gmail.com"],"social":{"facebook":null,"twitter":null,"skype":null,"msn":null,"linkedIn":null},"address":{"postalCode":null,"country":null,"state":null,"city":null,"district":null,"streetName":null,"streetNumber":null,"additionalInfo":null},"userOwner":null,"name":"Whatever","role":"Singer","ranking":null,"cpf":null}'
|
39
|
+
http_version: '1.1'
|
40
|
+
recorded_at: Mon, 02 Jun 2014 02:21:40 GMT
|
41
|
+
recorded_with: VCR 2.5.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agendor-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Ghisi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -153,8 +153,9 @@ files:
|
|
153
153
|
- VERSION
|
154
154
|
- agendor-ruby.gemspec
|
155
155
|
- lib/agendor-ruby.rb
|
156
|
-
- lib/api.rb
|
156
|
+
- lib/agendor/api.rb
|
157
157
|
- spec/api_spec.rb
|
158
|
+
- spec/cassettes/Agendor_Api/creates_a_person.yml
|
158
159
|
- spec/cassettes/Api/creates_a_person.yml
|
159
160
|
- spec/spec_helper.rb
|
160
161
|
homepage: http://github.com/brunogh/agendor-ruby
|
@@ -182,3 +183,4 @@ signing_key:
|
|
182
183
|
specification_version: 4
|
183
184
|
summary: Agendor CRM ruby client
|
184
185
|
test_files: []
|
186
|
+
has_rdoc:
|
data/lib/api.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
class Api
|
2
|
-
|
3
|
-
URL = "https://api.agendor.com.br/v1/people"
|
4
|
-
|
5
|
-
def initialize(username, password)
|
6
|
-
@username = username
|
7
|
-
@password = password
|
8
|
-
end
|
9
|
-
|
10
|
-
def add_person(params)
|
11
|
-
person = {
|
12
|
-
"name" => params[:name],
|
13
|
-
"role" => params[:role],
|
14
|
-
"emails" => params[:emails_array],
|
15
|
-
"description" => params[:description]
|
16
|
-
}
|
17
|
-
post = HTTParty.post(URL, :body => person.to_json, :headers => headers, :basic_auth => auth)
|
18
|
-
code = post.response.code
|
19
|
-
raise "Response not HTTP OK: #{code}" if code != "201"
|
20
|
-
code
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def auth
|
26
|
-
{:username => @username, :password => @password}
|
27
|
-
end
|
28
|
-
|
29
|
-
def headers
|
30
|
-
{ 'Content-Type' => "application/json" }
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|