passaporteweb-client 0.0.20 → 0.1.0

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: 6dae5ae2526d62d37b41abfc7fa5f8aac64e9074
4
- data.tar.gz: e1de8a6af24be995340ab96babbdd94fc4b6ae76
3
+ metadata.gz: 50735ee734dfb2049ece472d985bfd0f9f8fd008
4
+ data.tar.gz: 0ba448f5e9ef67388957666178a292cb04c14107
5
5
  SHA512:
6
- metadata.gz: c44ce37b4d9844ad3a1da98c3b74cd1aff8058ec50b9a18088151328fc69ec759b80c29a298d921da509199582a8549ef52d647976c1e4905fec5332f223e245
7
- data.tar.gz: 3ad47d884355a33192044583e27ad924f30526f91c51a53106822de20d48f23d7dc1a328c29073ea1ff867893bcdc98defde1cebbfa4b6739a762a51640b261d
6
+ metadata.gz: ec1334f13b99eefd6a3721f56a1ccc0f231daa86df75d83900611b4f1dbcb3ebd0347516fac7b6435b0a50cd8e26211de9fde72ab6bdabdc35c8781a3b4ff9b9
7
+ data.tar.gz: 2c8037c36d2cf24fb2ba290139b45a2c837845369e058626b186a7ca121de1466011994b02171daf29ab5bc51ce248050690f1f7508cf7e4832248fd46659a3f
data/.travis.yml CHANGED
@@ -1,7 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.9
4
- - 2.2.5
5
- - 2.3.1
6
- script:
7
- - bundle exec rake --trace spec
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.1
data/Gemfile.lock CHANGED
@@ -1,61 +1,55 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- passaporteweb-client (0.0.20)
5
- multi_json (~> 1.11.0)
4
+ passaporteweb-client (0.0.19)
5
+ multi_json (~> 1.9.0)
6
6
  rest-client (~> 1.6.7)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.4.0)
12
- awesome_print (1.7.0)
13
- coderay (1.1.1)
14
- coveralls (0.8.13)
15
- json (~> 1.8)
16
- simplecov (~> 0.11.0)
17
- term-ansicolor (~> 1.3)
18
- thor (~> 0.19.1)
19
- tins (~> 1.6.0)
20
- crack (0.4.3)
21
- safe_yaml (~> 1.0.0)
22
- diff-lcs (1.2.5)
23
- docile (1.1.5)
24
- json (1.8.3)
25
- method_source (0.8.2)
26
- mime-types (1.25.1)
27
- multi_json (1.11.3)
28
- pry (0.10.3)
29
- coderay (~> 1.1.0)
30
- method_source (~> 0.8.1)
11
+ addressable (2.3.3)
12
+ awesome_print (1.1.0)
13
+ coderay (1.0.9)
14
+ colorize (0.5.8)
15
+ coveralls (0.6.3)
16
+ colorize
17
+ multi_json (~> 1.3)
18
+ rest-client
19
+ simplecov (>= 0.7)
20
+ thor
21
+ crack (0.3.2)
22
+ diff-lcs (1.2.1)
23
+ json (1.7.7)
24
+ method_source (0.8.1)
25
+ mime-types (1.21)
26
+ multi_json (1.9.2)
27
+ pry (0.9.12)
28
+ coderay (~> 1.0.5)
29
+ method_source (~> 0.8)
31
30
  slop (~> 3.4)
32
- pry-nav (0.2.4)
33
- pry (>= 0.9.10, < 0.11.0)
34
- rake (10.5.0)
35
- rdoc (4.2.2)
31
+ pry-nav (0.2.3)
32
+ pry (~> 0.9.10)
33
+ rake (10.0.4)
34
+ rdoc (4.0.1)
36
35
  json (~> 1.4)
37
- rest-client (1.6.9)
38
- mime-types (~> 1.16)
39
- rspec (2.99.0)
40
- rspec-core (~> 2.99.0)
41
- rspec-expectations (~> 2.99.0)
42
- rspec-mocks (~> 2.99.0)
43
- rspec-core (2.99.2)
44
- rspec-expectations (2.99.2)
36
+ rest-client (1.6.7)
37
+ mime-types (>= 1.16)
38
+ rspec (2.13.0)
39
+ rspec-core (~> 2.13.0)
40
+ rspec-expectations (~> 2.13.0)
41
+ rspec-mocks (~> 2.13.0)
42
+ rspec-core (2.13.1)
43
+ rspec-expectations (2.13.0)
45
44
  diff-lcs (>= 1.1.3, < 2.0)
46
- rspec-mocks (2.99.4)
47
- safe_yaml (1.0.4)
48
- simplecov (0.11.2)
49
- docile (~> 1.1.0)
50
- json (~> 1.8)
51
- simplecov-html (~> 0.10.0)
52
- simplecov-html (0.10.0)
53
- slop (3.6.0)
54
- term-ansicolor (1.3.2)
55
- tins (~> 1.0)
56
- thor (0.19.1)
57
- tins (1.6.0)
58
- vcr (2.9.3)
45
+ rspec-mocks (2.13.0)
46
+ simplecov (0.7.1)
47
+ multi_json (~> 1.0)
48
+ simplecov-html (~> 0.7.1)
49
+ simplecov-html (0.7.1)
50
+ slop (3.4.4)
51
+ thor (0.18.0)
52
+ vcr (2.4.0)
59
53
  webmock (1.9.3)
60
54
  addressable (>= 2.2.7)
61
55
  crack (>= 0.3.2)
@@ -65,7 +59,7 @@ PLATFORMS
65
59
 
66
60
  DEPENDENCIES
67
61
  awesome_print (~> 1.1)
68
- bundler (>= 1.5.3)
62
+ bundler (~> 1.5.3)
69
63
  coveralls (~> 0.6)
70
64
  passaporteweb-client!
71
65
  pry (~> 0.9)
@@ -76,6 +70,3 @@ DEPENDENCIES
76
70
  simplecov (~> 0.7)
77
71
  vcr (~> 2.4)
78
72
  webmock (~> 1.9.3)
79
-
80
- BUNDLED WITH
81
- 1.12.5
data/README.rdoc CHANGED
@@ -61,6 +61,7 @@ Or install it yourself as:
61
61
  * {GET /accounts/api/service-info/:uuid/:service_slug/}[https://app.passaporteweb.com.br/static/docs/servicos.html#get-accounts-api-service-info-uuid-service-slug] ==> PassaporteWeb::IdentityService.find
62
62
  * {PUT /accounts/api/service-info/:uuid/:service_slug/}[https://app.passaporteweb.com.br/static/docs/servicos.html#put-accounts-api-service-info-uuid-service-slug] ==> PassaporteWeb::IdentityService#save
63
63
  * {Perfil}[https://app.passaporteweb.com.br/static/docs/perfil.html]
64
+ * {GET /accounts/api/identities/:uuid/profile/}[http://myfreecomm.github.io/passaporte-web/pweb/api/usuarios.html#get-accounts-api-identities-uuid-profile] ==> PassaporteWeb::Identity#profile
64
65
  * {GET /profile/api/info/:uuid/}[https://app.passaporteweb.com.br/static/docs/perfil.html#get-profile-api-info-uuid] ==> (deprecated, not going to be implemented)
65
66
  * {GET /profile/api/info/?email=:email}[https://app.passaporteweb.com.br/static/docs/perfil.html#get-profile-api-info-email-email] ==> (deprecated, not going to be implemented)
66
67
  * {PUT /profile/api/info/:uuid/}[https://app.passaporteweb.com.br/static/docs/perfil.html#put-profile-api-info-uuid] ==> (deprecated, not going to be implemented)
@@ -6,8 +6,8 @@ module PassaporteWeb
6
6
  class Identity
7
7
  include Attributable
8
8
 
9
- ATTRIBUTES = [:accounts, :birth_date, :country, :cpf, :email, :first_name, :gender, :id_token, :is_active, :language, :last_name, :nickname, :notifications, :send_myfreecomm_news, :send_partner_news, :services, :timezone, :update_info_url, :uuid, :password, :password2, :must_change_password, :inhibit_activation_message, :tos]
10
- UPDATABLE_ATTRIBUTES = [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone]
9
+ ATTRIBUTES = [:accounts, :birth_date, :country, :cpf, :email, :first_name, :gender, :id_token, :is_active, :language, :last_name, :nickname, :notifications, :send_myfreecomm_news, :send_partner_news, :services, :timezone, :update_info_url, :uuid, :password, :password2, :must_change_password, :inhibit_activation_message, :tos, :bio, :position, :city, :company, :profession, :identity_info_url, :state, :email_list]
10
+ UPDATABLE_ATTRIBUTES = [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone, :bio, :position, :city, :company, :profession, :state]
11
11
  CREATABLE_ATTRIBUTES = *(UPDATABLE_ATTRIBUTES + [:email, :password, :password2, :must_change_password, :tos, :inhibit_activation_message])
12
12
 
13
13
  attr_accessor *UPDATABLE_ATTRIBUTES
@@ -58,6 +58,20 @@ module PassaporteWeb
58
58
  load_identity(attributes_hash)
59
59
  end
60
60
 
61
+ # Finds an Identity Profile by it's UUID (UUIDs are unique on PassaporteWeb). Returns the Identity instance
62
+ # with all fields set if successful, including the email list (in case user has more than one email activated).
63
+ # Raises a <tt>RestClient::ResourceNotFound</tt> exception if no
64
+ # Identity exists with the supplied UUID.
65
+ #
66
+ # API method: <tt>GET /accounts/api/identities/:uuid/profile</tt>
67
+ #
68
+ # API documentation: http://myfreecomm.github.io/passaporte-web/pweb/api/usuarios.html#get-accounts-api-identities-uuid-profile
69
+ def self.profile(uuid)
70
+ response = Http.get("/accounts/api/identities/#{uuid}/profile")
71
+ attributes_hash = MultiJson.decode(response.body)
72
+ load_identity(attributes_hash)
73
+ end
74
+
61
75
  # Checks if an Identity exists on PassaporteWeb and if the password is correct. Returns an instance of
62
76
  # Identity for the supplied email if the password is correct (although with only basic attributes set).
63
77
  # Returns <tt>false</tt> if the password is wrong or if no Identity exists on PassaporteWeb with
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module PassaporteWeb
3
- VERSION = "0.0.20"
3
+ VERSION = "0.1.0"
4
4
  end
@@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_dependency "rest-client", "~> 1.6.7"
27
- spec.add_dependency "multi_json", "~> 1.11.0"
27
+ spec.add_dependency "multi_json", "~> 1.9.0"
28
28
 
29
- spec.add_development_dependency "bundler", ">= 1.5.3"
29
+ spec.add_development_dependency "bundler", "~> 1.5.3"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency 'rdoc', '~> 4.0'
32
32
  spec.add_development_dependency "rspec", "~> 2.13"
@@ -4,15 +4,15 @@ require 'spec_helper'
4
4
  describe PassaporteWeb::Identity do
5
5
 
6
6
  describe "constants" do
7
- it { described_class::ATTRIBUTES.should == [:accounts, :birth_date, :country, :cpf, :email, :first_name, :gender, :id_token, :is_active, :language, :last_name, :nickname, :notifications, :send_myfreecomm_news, :send_partner_news, :services, :timezone, :update_info_url, :uuid, :password, :password2, :must_change_password, :inhibit_activation_message, :tos] }
8
- it { described_class::UPDATABLE_ATTRIBUTES.should == [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone] }
9
- it { described_class::CREATABLE_ATTRIBUTES.should == [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone, :email, :password, :password2, :must_change_password, :tos, :inhibit_activation_message] }
7
+ it { described_class::ATTRIBUTES.should == [:accounts, :birth_date, :country, :cpf, :email, :first_name, :gender, :id_token, :is_active, :language, :last_name, :nickname, :notifications, :send_myfreecomm_news, :send_partner_news, :services, :timezone, :update_info_url, :uuid, :password, :password2, :must_change_password, :inhibit_activation_message, :tos, :bio, :position, :city, :company, :profession, :identity_info_url, :state, :email_list] }
8
+ it { described_class::UPDATABLE_ATTRIBUTES.should == [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone, :bio, :position, :city, :company, :profession, :state] }
9
+ it { described_class::CREATABLE_ATTRIBUTES.should == [:first_name, :last_name, :nickname, :cpf, :birth_date, :gender, :send_myfreecomm_news, :send_partner_news, :country, :language, :timezone, :bio, :position, :city, :company, :profession, :state, :email, :password, :password2, :must_change_password, :tos, :inhibit_activation_message] }
10
10
  end
11
11
 
12
12
  describe ".new" do
13
13
  it "should instanciate an empty object" do
14
14
  identity = described_class.new
15
- identity.attributes.should == {:accounts=>nil, :birth_date=>nil, :country=>nil, :cpf=>nil, :email=>nil, :first_name=>nil, :gender=>nil, :id_token => nil, :is_active=>nil, :language=>nil, :last_name=>nil, :nickname=>nil, :notifications=>nil, :send_myfreecomm_news=>nil, :send_partner_news=>nil, :services=>nil, :timezone=>nil, :update_info_url=>nil, :uuid=>nil, :password=>nil, :password2=>nil, :must_change_password=>nil, :inhibit_activation_message=>nil, :tos=>nil}
15
+ identity.attributes.should == {:accounts=>nil, :birth_date=>nil, :country=>nil, :cpf=>nil, :email=>nil, :first_name=>nil, :gender=>nil, :id_token=>nil, :is_active=>nil, :language=>nil, :last_name=>nil, :nickname=>nil, :notifications=>nil, :send_myfreecomm_news=>nil, :send_partner_news=>nil, :services=>nil, :timezone=>nil, :update_info_url=>nil, :uuid=>nil, :password=>nil, :password2=>nil, :must_change_password=>nil, :inhibit_activation_message=>nil, :tos=>nil, :bio=>nil, :position=>nil, :city=>nil, :company=>nil, :profession=>nil, :identity_info_url=>nil, :state=>nil, :email_list=>nil}
16
16
  end
17
17
  it "should instanciate an object with attributes set" do
18
18
  attributes = {
@@ -46,7 +46,7 @@ describe PassaporteWeb::Identity do
46
46
  "tos"=>nil
47
47
  }
48
48
  identity = described_class.new(attributes)
49
- identity.attributes.should == {:accounts=>[], :birth_date=>"1945-10-27", :country=>"Brasil", :cpf=>nil, :email=>"lula@example.com", :first_name=>"Luis Inácio", :gender=>"M", :id_token => nil, :is_active=>true, :language=>"pt_BR", :last_name=>"da Silva", :nickname=>"Lula", :notifications=>{"count"=>0, "list"=>"/notifications/api/"}, :send_myfreecomm_news=>false, :send_partner_news=>false, :services=>{"myfinance"=>"/accounts/api/service-info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/myfinance/", "account_manager"=>"/accounts/api/service-info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/account_manager/"}, :timezone=>"GMT-3", :update_info_url=>"/profile/api/info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/", :uuid=>"a5868d14-6529-477a-9c6b-a09dd42a7cd2", :password=>nil, :password2=>nil, :must_change_password=>nil, :inhibit_activation_message=>nil, :tos=>nil}
49
+ identity.attributes.should == {:accounts=>[], :birth_date=>"1945-10-27", :country=>"Brasil", :cpf=>nil, :email=>"lula@example.com", :first_name=>"Luis Inácio", :gender=>"M", :id_token=>nil, :is_active=>true, :language=>"pt_BR", :last_name=>"da Silva", :nickname=>"Lula", :notifications=>{"count"=>0, "list"=>"/notifications/api/"}, :send_myfreecomm_news=>false, :send_partner_news=>false, :services=>{"myfinance"=>"/accounts/api/service-info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/myfinance/", "account_manager"=>"/accounts/api/service-info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/account_manager/"}, :timezone=>"GMT-3", :update_info_url=>"/profile/api/info/a5868d14-6529-477a-9c6b-a09dd42a7cd2/", :uuid=>"a5868d14-6529-477a-9c6b-a09dd42a7cd2", :password=>nil, :password2=>nil, :must_change_password=>nil, :inhibit_activation_message=>nil, :tos=>nil, :bio=>nil, :position=>nil, :city=>nil, :company=>nil, :profession=>nil, :identity_info_url=>nil, :state=>nil, :email_list=>nil}
50
50
  identity.last_name.should == "da Silva"
51
51
  identity.is_active.should == true
52
52
  identity.timezone.should == "GMT-3"
@@ -185,6 +185,40 @@ describe PassaporteWeb::Identity do
185
185
  end
186
186
  end
187
187
 
188
+ describe ".profile", :vcr => true do
189
+ it "should find the requested profile by email" do
190
+ identity = described_class.profile('8923199e-6c43-415a-bbd1-2e302fdf8d96')
191
+ identity.should be_instance_of(described_class)
192
+ identity.bio.should == 'I\'m the Kingslayer!'
193
+ identity.position.should == 'Knight'
194
+ identity.language.should == 'ur'
195
+ identity.city.should == 'Casterly Rock'
196
+ identity.gender.should == 'M'
197
+ identity.company.should == 'Lannister House'
198
+ identity.profession.should == 'Kingslayer'
199
+ identity.identity_info_url.should == 'http://sandbox.app.passaporteweb.com.br/accounts/api/identities/8923199e-6c43-415a-bbd1-2e302fdf8d96/'
200
+ identity.state.should == 'AC'
201
+ identity.country.should == 'Westeros'
202
+ identity.birth_date.should == '1950-01-01'
203
+ identity.timezone.should == 'Pacific/Midway'
204
+ identity.nickname.should == 'Jaime'
205
+ identity.email_list.count.should == 2
206
+ # Primary e-mail
207
+ identity.email_list[0]['address'].should == 'jaime.lannister@mailinator.com'
208
+ identity.email_list[0]['is_primary'].should be_true
209
+ identity.email_list[0]['is_active'].should be_true
210
+ # Secondary email
211
+ identity.email_list[1]['address'].should == 'kingslayer@mailinator.com'
212
+ identity.email_list[1]['is_primary'].should be_false
213
+ identity.email_list[1]['is_active'].should be_true
214
+ end
215
+ it "should raise an error if no profiles exist with that email" do
216
+ expect {
217
+ described_class.profile("invalid-uuid")
218
+ }.to raise_error(RestClient::ResourceNotFound, '404 Resource Not Found')
219
+ end
220
+ end
221
+
188
222
  describe ".authenticate", vcr: true do
189
223
  it "should return an instance of Identity if the password is correct for the given email" do
190
224
  identity = described_class.authenticate('teste@teste.com', '123456')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passaporteweb-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Tassinari de Oliveira
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-22 00:00:00.000000000 Z
12
+ date: 2014-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -31,26 +31,26 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 1.11.0
34
+ version: 1.9.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 1.11.0
41
+ version: 1.9.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ">="
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 1.5.3
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 1.5.3
56
56
  - !ruby/object:Gem::Dependency
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  requirements: []
258
258
  rubyforge_project:
259
- rubygems_version: 2.5.1
259
+ rubygems_version: 2.0.14
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: 'A Ruby client for the PassaporteWeb REST API: https://app.passaporteweb.com.br/static/docs/'