tpaga 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tpaga/api/customer_api.rb +25 -23
- data/lib/tpaga/swagger/request.rb +26 -26
- data/tpaga.gemspec +3 -3
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 276563b880a8fe9ce405088712f16439583a8323
|
4
|
+
data.tar.gz: fc914eda52360a07b8a4ba6a86cfe8d5fd05670f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 813cf3fdc1715200d90d447aac9c811c188a9520593fa147d0732830216b151e350bbfb5d512960098a03a21776e1b0eb4e840be4b107f9b55aff52e07c2f6fd
|
7
|
+
data.tar.gz: 19885e27841096620a79d362fb9d4dec282aaaaa0640ec689d47b6843fa1ee1462049689d9d97f79b2bc67fe12e7b04bc8054ec8075de3f85b0c8e5a188af1ef
|
@@ -9,7 +9,7 @@ class CustomerAPI
|
|
9
9
|
URI.encode(string.to_s)
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
|
13
13
|
|
14
14
|
# Add a new Customer to the Merchant
|
15
15
|
# Creates a new `Customer` associated to the Merchant
|
@@ -32,7 +32,7 @@ class CustomerAPI
|
|
32
32
|
#resource path
|
33
33
|
path = "/customer"
|
34
34
|
|
35
|
-
|
35
|
+
|
36
36
|
# pull querystring keys from options
|
37
37
|
queryopts = options.select do |key,value|
|
38
38
|
query_param_keys.include? key
|
@@ -58,7 +58,7 @@ class CustomerAPI
|
|
58
58
|
end
|
59
59
|
post_body = array
|
60
60
|
|
61
|
-
else
|
61
|
+
else
|
62
62
|
if body.respond_to?("to_body".to_sym)
|
63
63
|
post_body = body.to_body
|
64
64
|
else
|
@@ -68,7 +68,7 @@ class CustomerAPI
|
|
68
68
|
end
|
69
69
|
# form parameter
|
70
70
|
form_parameter_hash = {}
|
71
|
-
|
71
|
+
|
72
72
|
|
73
73
|
|
74
74
|
# authentication setting
|
@@ -104,9 +104,9 @@ class CustomerAPI
|
|
104
104
|
|
105
105
|
#resource path
|
106
106
|
path = "/customer/{customer_id}/credit_card".sub('{' + 'customer_id' + '}', escapeString(customer_id))
|
107
|
+
|
107
108
|
|
108
|
-
|
109
|
-
|
109
|
+
|
110
110
|
# pull querystring keys from options
|
111
111
|
queryopts = options.select do |key,value|
|
112
112
|
query_param_keys.include? key
|
@@ -132,7 +132,7 @@ class CustomerAPI
|
|
132
132
|
end
|
133
133
|
post_body = array
|
134
134
|
|
135
|
-
else
|
135
|
+
else
|
136
136
|
if body.respond_to?("to_body".to_sym)
|
137
137
|
post_body = body.to_body
|
138
138
|
else
|
@@ -142,7 +142,7 @@ class CustomerAPI
|
|
142
142
|
end
|
143
143
|
# form parameter
|
144
144
|
form_parameter_hash = {}
|
145
|
-
|
145
|
+
|
146
146
|
|
147
147
|
|
148
148
|
# authentication setting
|
@@ -175,9 +175,9 @@ class CustomerAPI
|
|
175
175
|
|
176
176
|
#resource path
|
177
177
|
path = "/customer/{id}".sub('{' + 'id' + '}', escapeString(id))
|
178
|
+
|
178
179
|
|
179
|
-
|
180
|
-
|
180
|
+
|
181
181
|
# pull querystring keys from options
|
182
182
|
queryopts = options.select do |key,value|
|
183
183
|
query_param_keys.include? key
|
@@ -193,7 +193,7 @@ class CustomerAPI
|
|
193
193
|
post_body = nil
|
194
194
|
# form parameter
|
195
195
|
form_parameter_hash = {}
|
196
|
-
|
196
|
+
|
197
197
|
|
198
198
|
|
199
199
|
# authentication setting
|
@@ -226,9 +226,9 @@ class CustomerAPI
|
|
226
226
|
|
227
227
|
#resource path
|
228
228
|
path = "/customer/{id}".sub('{' + 'id' + '}', escapeString(id))
|
229
|
+
|
229
230
|
|
230
|
-
|
231
|
-
|
231
|
+
|
232
232
|
# pull querystring keys from options
|
233
233
|
queryopts = options.select do |key,value|
|
234
234
|
query_param_keys.include? key
|
@@ -244,14 +244,14 @@ class CustomerAPI
|
|
244
244
|
post_body = nil
|
245
245
|
# form parameter
|
246
246
|
form_parameter_hash = {}
|
247
|
-
|
247
|
+
|
248
248
|
|
249
249
|
|
250
250
|
# authentication setting
|
251
251
|
require_auth = true
|
252
252
|
|
253
253
|
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :form_params => form_parameter_hash, :body=>post_body, :require_auth => require_auth }).make
|
254
|
-
|
254
|
+
|
255
255
|
|
256
256
|
end
|
257
257
|
|
@@ -280,9 +280,10 @@ class CustomerAPI
|
|
280
280
|
|
281
281
|
#resource path
|
282
282
|
path = "/customer/{customer_id}/credit_card/{card_id}".sub('{' + 'customer_id' + '}', escapeString(customer_id))
|
283
|
-
|
284
|
-
|
283
|
+
.sub('{' + 'card_id' + '}', escapeString(card_id))
|
284
|
+
|
285
285
|
|
286
|
+
|
286
287
|
# pull querystring keys from options
|
287
288
|
queryopts = options.select do |key,value|
|
288
289
|
query_param_keys.include? key
|
@@ -298,7 +299,7 @@ class CustomerAPI
|
|
298
299
|
post_body = nil
|
299
300
|
# form parameter
|
300
301
|
form_parameter_hash = {}
|
301
|
-
|
302
|
+
|
302
303
|
|
303
304
|
|
304
305
|
# authentication setting
|
@@ -334,10 +335,10 @@ class CustomerAPI
|
|
334
335
|
|
335
336
|
#resource path
|
336
337
|
path = "/customer/{customer_id}/credit_card/{card_id}".sub('{' + 'customer_id' + '}', escapeString(customer_id))
|
337
|
-
|
338
|
-
|
339
|
-
|
338
|
+
.sub('{' + 'card_id' + '}', escapeString(card_id))
|
339
|
+
|
340
340
|
|
341
|
+
|
341
342
|
# pull querystring keys from options
|
342
343
|
queryopts = options.select do |key,value|
|
343
344
|
query_param_keys.include? key
|
@@ -353,16 +354,17 @@ class CustomerAPI
|
|
353
354
|
post_body = nil
|
354
355
|
# form parameter
|
355
356
|
form_parameter_hash = {}
|
356
|
-
|
357
|
+
|
357
358
|
|
358
359
|
|
359
360
|
# authentication setting
|
360
361
|
require_auth = true
|
361
362
|
|
362
363
|
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :form_params => form_parameter_hash, :body=>post_body, :require_auth => require_auth }).make
|
363
|
-
|
364
|
+
|
364
365
|
|
365
366
|
end
|
366
367
|
|
367
368
|
end
|
368
369
|
end
|
370
|
+
|
@@ -11,14 +11,13 @@ module Swagger
|
|
11
11
|
|
12
12
|
# All requests must have an HTTP method and a path
|
13
13
|
# Optionals parameters are :params, :headers, :body, :format, :host
|
14
|
-
#
|
14
|
+
#
|
15
15
|
def initialize(http_method, path, attributes={})
|
16
16
|
# initialize Swagger configuraiton if it has not been done so
|
17
17
|
Swagger.configure if Swagger.configuration.nil?
|
18
18
|
|
19
19
|
attributes[:format] ||= Swagger.configuration.format
|
20
20
|
attributes[:params] ||= {}
|
21
|
-
attributes[:params] = {} if attributes[:params].empty?
|
22
21
|
|
23
22
|
# set authentication based on configuration setting
|
24
23
|
if attributes[:require_auth]
|
@@ -54,21 +53,21 @@ module Swagger
|
|
54
53
|
|
55
54
|
# Construct a base URL
|
56
55
|
#
|
57
|
-
def url(options = {})
|
56
|
+
def url(options = {})
|
58
57
|
u = Addressable::URI.new(
|
59
58
|
:scheme => Swagger.configuration.scheme,
|
60
59
|
:host => Swagger.configuration.host,
|
61
60
|
:path => self.interpreted_path,
|
62
61
|
:query => self.query_string.sub(/\?/, '')
|
63
62
|
).to_s
|
64
|
-
|
63
|
+
|
65
64
|
# Drop trailing question mark, if present
|
66
65
|
u.sub! /\?$/, ''
|
67
|
-
|
66
|
+
|
68
67
|
# no longer needed as we no longer support obfuscated
|
69
68
|
## Obfuscate API key?
|
70
69
|
#u.sub! /api\_key=\w+/, 'api_key=YOUR_API_KEY' if options[:obfuscated]
|
71
|
-
|
70
|
+
|
72
71
|
u
|
73
72
|
end
|
74
73
|
|
@@ -97,19 +96,19 @@ module Swagger
|
|
97
96
|
# e.g. /words/blah => /words/blah.{format}
|
98
97
|
if Swagger.configuration.force_ending_format
|
99
98
|
unless ['.json', '.xml', '{format}'].any? {|s| p.downcase.include? s }
|
100
|
-
p = "#{p}.#{format}"
|
99
|
+
p = "#{p}.#{format}"
|
101
100
|
end
|
102
101
|
end
|
103
102
|
|
104
103
|
p = p.sub("{format}", self.format.to_s)
|
105
|
-
|
104
|
+
|
106
105
|
URI.encode [Swagger.configuration.base_path, p].join("/").gsub(/\/+/, '/')
|
107
106
|
end
|
108
|
-
|
107
|
+
|
109
108
|
# Massage the request body into a state of readiness
|
110
109
|
# If body is a hash, camelize all keys then convert to a json string
|
111
110
|
#
|
112
|
-
def body=(value)
|
111
|
+
def body=(value)
|
113
112
|
#comment: no need to use camelize keys
|
114
113
|
#if value.is_a?(Hash)
|
115
114
|
# value = value.inject({}) do |memo, (k,v)|
|
@@ -119,9 +118,9 @@ module Swagger
|
|
119
118
|
#end
|
120
119
|
@body = value
|
121
120
|
end
|
122
|
-
|
121
|
+
|
123
122
|
# If body is an object, JSONify it before making the actual request.
|
124
|
-
#
|
123
|
+
#
|
125
124
|
def outgoing_body
|
126
125
|
if @body.nil? && @form_params && !@form_params.empty?
|
127
126
|
data = form_params.dup
|
@@ -132,8 +131,8 @@ module Swagger
|
|
132
131
|
else
|
133
132
|
@body.is_a?(String) ? @body : @body.to_json
|
134
133
|
end
|
135
|
-
end
|
136
|
-
|
134
|
+
end
|
135
|
+
|
137
136
|
# Construct a query string from the query-string-type params
|
138
137
|
def query_string
|
139
138
|
|
@@ -152,58 +151,58 @@ module Swagger
|
|
152
151
|
|
153
152
|
query_values[key] = value.to_s
|
154
153
|
end
|
155
|
-
|
154
|
+
|
156
155
|
# We don't want to end up with '?' as our query string
|
157
156
|
# if there aren't really any params
|
158
157
|
return "" if query_values.blank?
|
159
|
-
|
158
|
+
|
160
159
|
# Addressable requires query_values to be set after initialization..
|
161
160
|
qs = Addressable::URI.new
|
162
161
|
qs.query_values = query_values
|
163
162
|
qs.to_s
|
164
163
|
end
|
165
|
-
|
164
|
+
|
166
165
|
def make
|
167
166
|
response = case self.http_method.to_sym
|
168
167
|
when :get,:GET
|
169
168
|
Typhoeus::Request.get(
|
170
169
|
self.url,
|
171
|
-
:headers => self.headers.stringify_keys
|
170
|
+
:headers => self.headers.stringify_keys,
|
172
171
|
)
|
173
172
|
|
174
173
|
when :post,:POST
|
175
174
|
Typhoeus::Request.post(
|
176
175
|
self.url,
|
177
176
|
:body => self.outgoing_body,
|
178
|
-
:headers => self.headers.stringify_keys
|
177
|
+
:headers => self.headers.stringify_keys,
|
179
178
|
)
|
180
179
|
|
181
180
|
when :put,:PUT
|
182
181
|
Typhoeus::Request.put(
|
183
182
|
self.url,
|
184
183
|
:body => self.outgoing_body,
|
185
|
-
:headers => self.headers.stringify_keys
|
184
|
+
:headers => self.headers.stringify_keys,
|
186
185
|
)
|
187
|
-
|
186
|
+
|
188
187
|
when :delete,:DELETE
|
189
188
|
Typhoeus::Request.delete(
|
190
189
|
self.url,
|
191
190
|
:body => self.outgoing_body,
|
192
|
-
:headers => self.headers.stringify_keys
|
191
|
+
:headers => self.headers.stringify_keys,
|
193
192
|
)
|
194
193
|
end
|
195
194
|
Response.new(response)
|
196
195
|
end
|
197
|
-
|
196
|
+
|
198
197
|
def response
|
199
198
|
self.make
|
200
199
|
end
|
201
|
-
|
200
|
+
|
202
201
|
def response_code_pretty
|
203
202
|
return unless @response.present?
|
204
|
-
@response.code.to_s
|
203
|
+
@response.code.to_s
|
205
204
|
end
|
206
|
-
|
205
|
+
|
207
206
|
def response_headers_pretty
|
208
207
|
return unless @response.present?
|
209
208
|
# JSON.pretty_generate(@response.headers).gsub(/\n/, '<br/>') # <- This was for RestClient
|
@@ -213,3 +212,4 @@ module Swagger
|
|
213
212
|
end
|
214
213
|
end
|
215
214
|
end
|
215
|
+
|
data/tpaga.gemspec
CHANGED
@@ -3,8 +3,8 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "tpaga"
|
6
|
-
s.date = "2015-
|
7
|
-
s.version = "0.0.
|
6
|
+
s.date = "2015-03-10"
|
7
|
+
s.version = "0.0.3"
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Sebastian Ortiz V."]
|
10
10
|
s.email = ["sortiz@tpaga.co"]
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.license = 'Apache License, Version 2.0'
|
20
20
|
|
21
21
|
s.add_runtime_dependency 'typhoeus', '~> 0.2', '>= 0.2.1'
|
22
|
-
s.add_runtime_dependency 'addressable', '2.2.
|
22
|
+
s.add_runtime_dependency 'addressable', '~> 2.2', '>= 2.2.4'
|
23
23
|
s.add_runtime_dependency 'json', '~> 1.4', '>= 1.4.6'
|
24
24
|
|
25
25
|
s.files = `find *`.split("
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tpaga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Ortiz V.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -34,16 +34,22 @@ dependencies:
|
|
34
34
|
name: addressable
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.2'
|
40
|
+
- - ">="
|
38
41
|
- !ruby/object:Gem::Version
|
39
|
-
version: 2.2.
|
42
|
+
version: 2.2.4
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- -
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.2'
|
50
|
+
- - ">="
|
45
51
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.2.
|
52
|
+
version: 2.2.4
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: json
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
120
|
version: '0'
|
115
121
|
requirements: []
|
116
122
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.4.
|
123
|
+
rubygems_version: 2.4.5
|
118
124
|
signing_key:
|
119
125
|
specification_version: 4
|
120
126
|
summary: TPaga API Ruby Bindings powered by Swagger
|