gerencianet 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/CHANGELOG.md +8 -0
- data/README.md +15 -3
- data/docs/all-in-one.md +92 -0
- data/docs/carnet-detailing.md +61 -0
- data/docs/carnet-update.md +55 -0
- data/docs/carnets.md +217 -0
- data/docs/charge-detailing.md +42 -0
- data/docs/charge-payment.md +145 -0
- data/docs/charge-update.md +52 -0
- data/docs/charge-with-marketplace.md +54 -0
- data/docs/charges.md +94 -0
- data/docs/examples/.gitignore +1 -0
- data/docs/examples/all_in_one.rb +57 -0
- data/docs/examples/cancel_charge.rb +15 -0
- data/docs/examples/cancel_subscription.rb +15 -0
- data/docs/examples/create_billet_payment.rb +33 -0
- data/docs/examples/create_card_payment.rb +39 -0
- data/docs/examples/create_carnet.rb +32 -0
- data/docs/examples/create_charge.rb +24 -0
- data/docs/examples/create_plan.rb +17 -0
- data/docs/examples/create_subscription.rb +31 -0
- data/docs/examples/create_subscription_payment.rb +38 -0
- data/docs/examples/credentials.rb +5 -0
- data/docs/examples/delete_plan.rb +15 -0
- data/docs/examples/detail_carnet.rb +15 -0
- data/docs/examples/detail_charge.rb +15 -0
- data/docs/examples/detail_subscription.rb +15 -0
- data/docs/examples/get_installments.rb +16 -0
- data/docs/examples/get_notification.rb +15 -0
- data/docs/examples/get_plans.rb +17 -0
- data/docs/examples/update_billet.rb +19 -0
- data/docs/examples/update_carnet_metadata.rb +20 -0
- data/docs/examples/update_charge_metadata.rb +20 -0
- data/docs/examples/update_parcel.rb +20 -0
- data/docs/examples/update_subscription_metadata.rb +20 -0
- data/docs/installments.md +108 -0
- data/docs/notifications.md +105 -0
- data/docs/subscription-detailing.md +56 -0
- data/docs/subscription-payment.md +100 -0
- data/docs/subscription-update.md +29 -0
- data/docs/subscriptions.md +69 -0
- data/lib/gerencianet/constants.rb +1 -1
- data/lib/gerencianet/endpoints.rb +14 -19
- data/lib/gerencianet/version.rb +1 -1
- metadata +41 -2
@@ -26,8 +26,8 @@ module Gerencianet
|
|
26
26
|
|
27
27
|
def create_methods
|
28
28
|
@endpoints.each do |key, settings|
|
29
|
-
self.class.send(:define_method, key) do |
|
30
|
-
create(params, body, settings)
|
29
|
+
self.class.send(:define_method, key) do |args = {}|
|
30
|
+
create(args[:params], args[:body], settings)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -42,7 +42,7 @@ module Gerencianet
|
|
42
42
|
response = make_request(params, body, settings)
|
43
43
|
end
|
44
44
|
|
45
|
-
response
|
45
|
+
respond(response)
|
46
46
|
end
|
47
47
|
|
48
48
|
def make_request(params, body, settings)
|
@@ -59,10 +59,15 @@ module Gerencianet
|
|
59
59
|
url = get_url({}, @endpoints[:authorize][:route])
|
60
60
|
|
61
61
|
response =
|
62
|
-
HTTP
|
62
|
+
HTTP
|
63
|
+
.basic_auth(auth_headers)
|
63
64
|
.post(url, json: auth_body)
|
64
65
|
|
65
|
-
|
66
|
+
if response.status.to_s == STATUS::UNAUTHORIZED
|
67
|
+
fail "unable to authenticate"
|
68
|
+
else
|
69
|
+
@token = respond(response)
|
70
|
+
end
|
66
71
|
end
|
67
72
|
|
68
73
|
def auth_headers
|
@@ -77,15 +82,9 @@ module Gerencianet
|
|
77
82
|
end
|
78
83
|
|
79
84
|
def respond(response)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
rescue JSON::ParserError
|
84
|
-
raise "unable to parse server response, not a valid json"
|
85
|
-
end
|
86
|
-
else
|
87
|
-
fail "unable to authenticate"
|
88
|
-
end
|
85
|
+
JSON.parse(response)
|
86
|
+
rescue JSON::ParserError
|
87
|
+
raise "unable to parse server response, not a valid json"
|
89
88
|
end
|
90
89
|
|
91
90
|
def get_url(params, route)
|
@@ -123,11 +122,7 @@ module Gerencianet
|
|
123
122
|
end
|
124
123
|
|
125
124
|
def current_base_url
|
126
|
-
|
127
|
-
@urls[:sandbox]
|
128
|
-
else
|
129
|
-
@urls[:production]
|
130
|
-
end
|
125
|
+
@options[:sandbox] ? @urls[:sandbox] : @urls[:production]
|
131
126
|
end
|
132
127
|
end
|
133
128
|
end
|
data/lib/gerencianet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gerencianet
|
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
|
- Francisco Carvalho
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,6 +170,45 @@ files:
|
|
170
170
|
- Rakefile
|
171
171
|
- bin/console
|
172
172
|
- bin/setup
|
173
|
+
- docs/all-in-one.md
|
174
|
+
- docs/carnet-detailing.md
|
175
|
+
- docs/carnet-update.md
|
176
|
+
- docs/carnets.md
|
177
|
+
- docs/charge-detailing.md
|
178
|
+
- docs/charge-payment.md
|
179
|
+
- docs/charge-update.md
|
180
|
+
- docs/charge-with-marketplace.md
|
181
|
+
- docs/charges.md
|
182
|
+
- docs/examples/.gitignore
|
183
|
+
- docs/examples/all_in_one.rb
|
184
|
+
- docs/examples/cancel_charge.rb
|
185
|
+
- docs/examples/cancel_subscription.rb
|
186
|
+
- docs/examples/create_billet_payment.rb
|
187
|
+
- docs/examples/create_card_payment.rb
|
188
|
+
- docs/examples/create_carnet.rb
|
189
|
+
- docs/examples/create_charge.rb
|
190
|
+
- docs/examples/create_plan.rb
|
191
|
+
- docs/examples/create_subscription.rb
|
192
|
+
- docs/examples/create_subscription_payment.rb
|
193
|
+
- docs/examples/credentials.rb
|
194
|
+
- docs/examples/delete_plan.rb
|
195
|
+
- docs/examples/detail_carnet.rb
|
196
|
+
- docs/examples/detail_charge.rb
|
197
|
+
- docs/examples/detail_subscription.rb
|
198
|
+
- docs/examples/get_installments.rb
|
199
|
+
- docs/examples/get_notification.rb
|
200
|
+
- docs/examples/get_plans.rb
|
201
|
+
- docs/examples/update_billet.rb
|
202
|
+
- docs/examples/update_carnet_metadata.rb
|
203
|
+
- docs/examples/update_charge_metadata.rb
|
204
|
+
- docs/examples/update_parcel.rb
|
205
|
+
- docs/examples/update_subscription_metadata.rb
|
206
|
+
- docs/installments.md
|
207
|
+
- docs/notifications.md
|
208
|
+
- docs/subscription-detailing.md
|
209
|
+
- docs/subscription-payment.md
|
210
|
+
- docs/subscription-update.md
|
211
|
+
- docs/subscriptions.md
|
173
212
|
- gerencianet.gemspec
|
174
213
|
- lib/gerencianet.rb
|
175
214
|
- lib/gerencianet/constants.rb
|