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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fb2c0e91cbd4a4bb3f844ad245ab6d856b007b2
4
- data.tar.gz: babb7fba8fcd1b77b8d3eb344c77504a2ac5efa3
3
+ metadata.gz: 73ef87c6d7da05894f6161bf0a7a856edb564647
4
+ data.tar.gz: ef6fe0253aee276f606fd4b08651bfe3d0db7a99
5
5
  SHA512:
6
- metadata.gz: 649090d527db983528033f8be8775e975fde7c8b38070fb4163273dc500a3df9dba96cc2ab6e7d8822beeafe52ce166f5b9a4fa122dc99eff03c05bd3323256b
7
- data.tar.gz: 10d5a7c4fc0f6361314b276436d15b7fc5dbf6bb098ecbce21d4006d0e229ef08faae21f4e00e03fbd65d7d777d8390753592b3ea4d5cd8551de3b8bac2b1281
6
+ metadata.gz: b6d3331029c4d57e11d5c77ba6ad6249efe8d2e731089d899b204d222a61dce0096402935bb460cca6e0a8e2257d77bdf2553997ad9dc6016841c6dd9a954209
7
+ data.tar.gz: faa463e781478ccf05438b9c97bf14399c11c61f7b9d319b7bb4009a7abf862ba8aeeba16c0ed8be1cece967ba5fe94a90e4633935efaea2d2939045d4a2aebb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "agendor-ruby"
8
- s.version = "0.0.1"
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-01"
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
  ]
@@ -1,2 +1,2 @@
1
- require "api"
1
+ require "agendor/api"
2
2
  require 'httparty'
@@ -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
@@ -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.1
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-01 00:00:00.000000000 Z
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