moip-assinaturas 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/moip-assinaturas/client.rb +12 -5
- data/lib/moip-assinaturas/version.rb +1 -1
- data/spec/moip-assinaturas/payment_spec.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76f00ea4681da01e03de533471378518d581fe6c
|
4
|
+
data.tar.gz: a842c2a3fb41f18b2bfe51c75f0f48a02c77d424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
135
|
-
|
136
|
-
|
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]
|
@@ -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.
|
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-
|
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.
|
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
|