moip-assinaturas 0.5.1 → 0.6.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: 90319baed9474a2582902023e872851c91c7958c
4
- data.tar.gz: 512e1e40e2f422da9eb2c8d8a5e64d2a9572e6db
3
+ metadata.gz: 76f00ea4681da01e03de533471378518d581fe6c
4
+ data.tar.gz: a842c2a3fb41f18b2bfe51c75f0f48a02c77d424
5
5
  SHA512:
6
- metadata.gz: 00c8eda0d89c7cc94d9aab67173268ff8f2b005fda1838dbe647d476e43a09ef01dda639f7c7f1fbab063d9a4bca65e8a11761b846f8aeaf6e37d5d7d50abbca
7
- data.tar.gz: fe233a408e013416d5924e5d42ee33149d70cf7bef8dc3600edf927725403bb9bcf93cbffef4a4c93df8645e66c1fc6d4385718720dafebc288e1ca8771f7ad4
6
+ metadata.gz: 011de40566401a5a5994a929aa7daa05a8873b1104a3f952802e8c0002f80307a4dd6936d96b6221db7e8c31483b9bac24a33938998370e8e6ef97e30592d329
7
+ data.tar.gz: ae361bb9f2b9167ccf1fc4e2c6d7ffc68f99ccfe021539853e69ac21f8711d1bf16167ce391c5ece56dc0b64984b9aaf83678c07783bc069c3301da66ec8169a
@@ -126,15 +126,22 @@ module Moip::Assinaturas
126
126
  end
127
127
 
128
128
  private
129
+ def oauth?(authorization_hash)
130
+ raise MissingTokenError.new if authorization_hash.nil? || !authorization_hash.downcase.include?("oauth")
131
+ end
129
132
 
130
133
  def prepare_options(custom_options, required_options)
131
134
  custom_options.merge!(required_options)
132
-
133
135
  if custom_options.include?(:moip_auth)
134
- custom_options[:basic_auth] = {
135
- username: custom_options[:moip_auth][:token],
136
- password: custom_options[:moip_auth][:key]
137
- }
136
+
137
+ if custom_options[:moip_auth][:token] && custom_options[:moip_auth][:key]
138
+ custom_options[:basic_auth] = {
139
+ username: custom_options[:moip_auth][:token],
140
+ password: custom_options[:moip_auth][:key]
141
+ }
142
+ elsif oauth? custom_options[:moip_auth][:oauth][:accessToken]
143
+ custom_options[:authorization] = "OAuth #{custom_options[:moip_auth][:oauth][:accessToken]}"
144
+ end
138
145
 
139
146
  if custom_options[:moip_auth].include?(:sandbox)
140
147
  if custom_options[:moip_auth][:sandbox]
@@ -1,5 +1,5 @@
1
1
  module Moip
2
2
  module Assinaturas
3
- VERSION = "0.5.1"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -59,5 +59,13 @@ describe Moip::Assinaturas::Payment do
59
59
  request[:success].should be_true
60
60
  request[:payment][:id].should == 7
61
61
  end
62
+
63
+ it "should raise exception from invalid oauth" do
64
+ expect{ Moip::Assinaturas::Payment.details(7, moip_auth: { oauth: {accessToken: "sefghjrs"}, sandbox: true})}.to raise_error Moip::Assinaturas::MissingTokenError
65
+ end
66
+
67
+ it "shoul raise exception from nil oauth" do
68
+ expect{ Moip::Assinaturas::Payment.details(7, moip_auth: { oauth: {accessToken: ""}, sandbox: true })}.to raise_error Moip::Assinaturas::MissingTokenError
69
+ end
62
70
  end
63
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moip-assinaturas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warlley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -217,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  version: '0'
218
218
  requirements: []
219
219
  rubyforge_project:
220
- rubygems_version: 2.4.2
220
+ rubygems_version: 2.4.6
221
221
  signing_key:
222
222
  specification_version: 4
223
223
  summary: Ruby Gem para uso do serviço de assinaturas do Moip