compropago_sdk 3.1.2 → 3.1.2.1
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/compropago_sdk/client.rb +1 -1
- data/lib/compropago_sdk/factory/factory.rb +0 -0
- data/lib/compropago_sdk/factory/models/cp_order_info.rb +0 -0
- data/lib/compropago_sdk/factory/models/customer.rb +0 -0
- data/lib/compropago_sdk/factory/models/eval_auth_info.rb +0 -0
- data/lib/compropago_sdk/factory/models/exchange.rb +0 -0
- data/lib/compropago_sdk/factory/models/fee_details.rb +0 -0
- data/lib/compropago_sdk/factory/models/instruction_details.rb +0 -0
- data/lib/compropago_sdk/factory/models/instructions.rb +0 -0
- data/lib/compropago_sdk/factory/models/new_order_info.rb +0 -0
- data/lib/compropago_sdk/factory/models/order_info.rb +0 -0
- data/lib/compropago_sdk/factory/models/place_order_info.rb +0 -0
- data/lib/compropago_sdk/factory/models/provider.rb +1 -0
- data/lib/compropago_sdk/factory/models/sms_data.rb +0 -0
- data/lib/compropago_sdk/factory/models/sms_info.rb +0 -0
- data/lib/compropago_sdk/factory/models/sms_object.rb +0 -0
- data/lib/compropago_sdk/factory/models/webhook.rb +0 -0
- data/lib/compropago_sdk/factory/serialize.rb +2 -1
- data/lib/compropago_sdk/service.rb +61 -69
- data/lib/compropago_sdk/tools/validations.rb +17 -1
- data/lib/compropago_sdk.rb +0 -0
- metadata +15 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1e438fb001c675367c2a1e7274194267f1e6448
|
|
4
|
+
data.tar.gz: e0baa501aa4ed0dd94466bae11acbfa97cca16f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 76d2acb5b3d11f0d7a98f5c680a47f289dfeceb030988c61a8cb1fb2b3481d393b6346918e302bdfda00f97b4c8b207990085d362accb06e6c77199f53add3c1
|
|
7
|
+
data.tar.gz: acc799aec7d970f3035770ab963e35dbadbd4b06986ec0c84e21e9776b89a7b0fbe6a2fbf2edf9d77c5a134d188e8863fbf0d209f5d2f5e1b2eb2848b5182d99
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -14,7 +14,7 @@ class Serialize
|
|
|
14
14
|
data[:currency] ? data[:currency] : 'MXN',
|
|
15
15
|
data[:expiration_time] ? data[:expiration_time] : nil,
|
|
16
16
|
data[:image_url] ? data[:image_url] : '',
|
|
17
|
-
data[:app_client_name] ? data[:app_client_name] : '
|
|
17
|
+
data[:app_client_name] ? data[:app_client_name] : 'sdkruby',
|
|
18
18
|
data[:app_client_version] ? data[:app_client_version] : Client::VERSION,
|
|
19
19
|
)
|
|
20
20
|
end
|
|
@@ -215,6 +215,7 @@ class Serialize
|
|
|
215
215
|
obj.image_large = data['image_large']
|
|
216
216
|
obj.transaction_limit = data['transaction_limit']
|
|
217
217
|
obj.rank = data['rank']
|
|
218
|
+
obj.commission = data['commission']
|
|
218
219
|
|
|
219
220
|
return obj
|
|
220
221
|
end
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
class Service
|
|
2
|
-
#
|
|
2
|
+
# Constructor
|
|
3
|
+
#
|
|
4
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
3
5
|
def initialize(client)
|
|
4
6
|
@client = client
|
|
5
7
|
end
|
|
6
8
|
|
|
7
|
-
#
|
|
9
|
+
# Get auth params
|
|
10
|
+
#
|
|
8
11
|
# @return [Hash]
|
|
12
|
+
#
|
|
13
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
9
14
|
def get_auth
|
|
10
15
|
{ :user => @client.get_user, :pass => @client.get_pass }
|
|
11
16
|
end
|
|
12
17
|
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
# @param
|
|
18
|
+
# List providers by limit and currency
|
|
19
|
+
#
|
|
20
|
+
# @param [float] limit limite de transaccion de los proveedores
|
|
21
|
+
# @param [string] currency
|
|
22
|
+
# @return [Array]
|
|
23
|
+
#
|
|
24
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
16
25
|
def list_providers(limit=0, currency='MXN')
|
|
17
26
|
uri = @client.deploy_uri+'providers/'
|
|
18
27
|
|
|
@@ -25,21 +34,26 @@ class Service
|
|
|
25
34
|
end
|
|
26
35
|
|
|
27
36
|
response = EasyRequest::get(uri, get_auth())
|
|
28
|
-
|
|
29
|
-
Factory::get_instance_of 'ListProviders', response
|
|
37
|
+
Factory::get_instance_of('ListProviders', response)
|
|
30
38
|
end
|
|
31
39
|
|
|
32
|
-
#
|
|
40
|
+
# Verify order by unique_id
|
|
41
|
+
#
|
|
42
|
+
# @param [string] order_id
|
|
33
43
|
# @return [CpOrderInfo]
|
|
44
|
+
#
|
|
45
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
34
46
|
def verify_order(order_id)
|
|
35
47
|
response = EasyRequest::get( @client.deploy_uri+'charges/'+order_id+'/', get_auth())
|
|
36
|
-
|
|
37
|
-
Factory::get_instance_of 'CpOrderInfo', response
|
|
48
|
+
Factory::get_instance_of('CpOrderInfo', response)
|
|
38
49
|
end
|
|
39
50
|
|
|
40
|
-
#
|
|
41
|
-
#
|
|
51
|
+
# Place order
|
|
52
|
+
#
|
|
53
|
+
# @param [PlaceOrderInfo] order
|
|
42
54
|
# @return [NewOrderInfo]
|
|
55
|
+
#
|
|
56
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
43
57
|
def place_order(order)
|
|
44
58
|
unless order.is_a?(PlaceOrderInfo)
|
|
45
59
|
raise 'Order object is not valid'
|
|
@@ -56,91 +70,69 @@ class Service
|
|
|
56
70
|
expiration_time: order.expiration_time,
|
|
57
71
|
image_url: order.image_url,
|
|
58
72
|
app_client_name: order.app_client_name,
|
|
59
|
-
app_client_version: order.app_client_version
|
|
60
|
-
ip_address: get_ip()
|
|
73
|
+
app_client_version: order.app_client_version
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
puts params
|
|
64
|
-
|
|
65
76
|
response = EasyRequest::post(@client.deploy_uri+'charges/', params, get_auth())
|
|
66
|
-
|
|
67
|
-
Factory::get_instance_of 'NewOrderInfo', response
|
|
77
|
+
Factory::get_instance_of('NewOrderInfo', response)
|
|
68
78
|
end
|
|
69
79
|
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
# @param
|
|
80
|
+
# Send sms of an order
|
|
81
|
+
#
|
|
82
|
+
# @param [string] number phone number
|
|
83
|
+
# @param [string] order_id id de la orden generada
|
|
73
84
|
# @return [SmsInfo]
|
|
85
|
+
#
|
|
86
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
74
87
|
def send_sms_instructions(number, order_id)
|
|
75
88
|
params = {customer_phone: number}
|
|
76
|
-
|
|
77
89
|
response = EasyRequest::post(@client.deploy_uri+'charges/'+order_id+'/sms/', params, get_auth())
|
|
78
|
-
|
|
79
|
-
Factory::get_instance_of 'SmsInfo', response
|
|
90
|
+
Factory::get_instance_of('SmsInfo', response)
|
|
80
91
|
end
|
|
81
92
|
|
|
82
|
-
#
|
|
83
|
-
#
|
|
93
|
+
# Creatre webhook
|
|
94
|
+
#
|
|
95
|
+
# @param [string] url
|
|
84
96
|
# @return [Webhook]
|
|
97
|
+
#
|
|
98
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
85
99
|
def create_webhook(url)
|
|
86
100
|
params = {url: url}
|
|
87
|
-
|
|
88
101
|
response = EasyRequest::post(@client.deploy_uri+'webhooks/stores/', params, get_auth())
|
|
89
|
-
|
|
90
|
-
Factory::get_instance_of 'Webhook', response
|
|
102
|
+
Factory::get_instance_of('Webhook', response)
|
|
91
103
|
end
|
|
92
104
|
|
|
93
|
-
#
|
|
94
|
-
#
|
|
95
|
-
# @param
|
|
96
|
-
# @
|
|
105
|
+
# Update registered webhook
|
|
106
|
+
#
|
|
107
|
+
# @param [string] webhook_id registered webhook ID
|
|
108
|
+
# @param [string] new_url new url for the webhook
|
|
109
|
+
# @return [Webhook]
|
|
110
|
+
#
|
|
111
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
97
112
|
def update_webhook(webhook_id, new_url)
|
|
98
113
|
params = {url: new_url}
|
|
99
|
-
|
|
100
114
|
response = EasyRequest::put(@client.deploy_uri+'webhooks/stores/'+webhook_id+'/', params, get_auth())
|
|
101
|
-
|
|
102
|
-
Factory::get_instance_of 'Webhook', response
|
|
115
|
+
Factory::get_instance_of('Webhook', response)
|
|
103
116
|
end
|
|
104
117
|
|
|
105
|
-
#
|
|
106
|
-
#
|
|
118
|
+
# Delete webhook
|
|
119
|
+
#
|
|
120
|
+
# @param [string] webhook_id registered webhook ID
|
|
107
121
|
# @param [Webhook]
|
|
122
|
+
#
|
|
123
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
108
124
|
def delete_webhook(webhook_id)
|
|
109
125
|
response = EasyRequest::delete(@client.deploy_uri+'webhooks/stores/'+webhook_id, nil, get_auth())
|
|
110
|
-
|
|
111
|
-
Factory::get_instance_of 'Webhook', response
|
|
126
|
+
Factory::get_instance_of('Webhook', response)
|
|
112
127
|
end
|
|
113
128
|
|
|
114
|
-
#
|
|
115
|
-
#
|
|
129
|
+
# Get list registered webhooks
|
|
130
|
+
#
|
|
131
|
+
# @return [Array]
|
|
132
|
+
#
|
|
133
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
116
134
|
def list_webhooks
|
|
117
135
|
response = EasyRequest::get(@client.deploy_uri+'webhooks/stores/', get_auth())
|
|
118
|
-
|
|
119
|
-
Factory::get_instance_of 'ListWebhooks', response
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
# FUNCTION: send async glocation for an order
|
|
123
|
-
# @param order_id [String] id de la orden generada
|
|
124
|
-
# @param latitud [Int] latitud de localizacion
|
|
125
|
-
# @param longitud [Int] longitud de localizacion
|
|
126
|
-
def send_glocation(order_id, latitud, longitud)
|
|
127
|
-
begin
|
|
128
|
-
data = {
|
|
129
|
-
latitud: latitud,
|
|
130
|
-
longitud: longitud,
|
|
131
|
-
order_id: order_id
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
response = EasyRequest.post(@client.deploy_uri+'glocation', data, get_auth())
|
|
135
|
-
puts response
|
|
136
|
-
rescue => exception
|
|
137
|
-
puts exception.message
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# FUNCTION: get real IP request
|
|
142
|
-
# @return [String]
|
|
143
|
-
private def get_ip
|
|
144
|
-
return Net::HTTP.get URI "https://api.ipify.org"
|
|
136
|
+
Factory::get_instance_of('ListWebhooks', response)
|
|
145
137
|
end
|
|
146
138
|
end
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
class Validations
|
|
2
2
|
|
|
3
|
+
# Obtain auth info
|
|
4
|
+
#
|
|
5
|
+
# @param [Client] client
|
|
6
|
+
# @return [EvalAuthInfo]
|
|
7
|
+
# @raise [Error]
|
|
8
|
+
#
|
|
9
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
3
10
|
def self.eval_auth(client)
|
|
4
11
|
response = EasyRequest::get(client.deploy_uri+'users/auth/', user: client.get_user, pass: client.get_pass)
|
|
5
12
|
info = Factory.get_instance_of('EvalAuthInfo', response)
|
|
@@ -11,6 +18,13 @@ class Validations
|
|
|
11
18
|
end
|
|
12
19
|
end
|
|
13
20
|
|
|
21
|
+
# Validate client instance
|
|
22
|
+
#
|
|
23
|
+
# @param [Client] client
|
|
24
|
+
# @return [bool]
|
|
25
|
+
# @raise [Error]
|
|
26
|
+
#
|
|
27
|
+
# @author Eduardo Aguilar <dante.aguilar41@gmail.com>
|
|
14
28
|
def self.validate_gateway(client)
|
|
15
29
|
unless client
|
|
16
30
|
raise 'Client object is not valid'
|
|
@@ -18,7 +32,7 @@ class Validations
|
|
|
18
32
|
|
|
19
33
|
client_mode = client.live
|
|
20
34
|
|
|
21
|
-
auth_info = Validations::eval_auth
|
|
35
|
+
auth_info = Validations::eval_auth(client)
|
|
22
36
|
|
|
23
37
|
if auth_info.mode_key != auth_info.livemode
|
|
24
38
|
raise 'Keys are diferent of store mode.'
|
|
@@ -31,6 +45,8 @@ class Validations
|
|
|
31
45
|
if client_mode != auth_info.mode_key
|
|
32
46
|
raise 'Client mode is diferent of keys mode'
|
|
33
47
|
end
|
|
48
|
+
|
|
49
|
+
return true
|
|
34
50
|
end
|
|
35
51
|
|
|
36
52
|
end
|
data/lib/compropago_sdk.rb
CHANGED
|
File without changes
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: compropago_sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.1.2
|
|
4
|
+
version: 3.1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eduardo Aguilar
|
|
@@ -9,50 +9,50 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2017-
|
|
12
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
requirements:
|
|
18
|
-
- - "
|
|
18
|
+
- - ">="
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '
|
|
20
|
+
version: '0'
|
|
21
21
|
type: :development
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
|
-
- - "
|
|
25
|
+
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '
|
|
27
|
+
version: '0'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: rake
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- - "
|
|
32
|
+
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
34
|
+
version: '0'
|
|
35
35
|
type: :development
|
|
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: '
|
|
41
|
+
version: '0'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
43
|
name: minitest
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
|
-
- - "
|
|
46
|
+
- - ">="
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '
|
|
48
|
+
version: '0'
|
|
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
|
-
version: '
|
|
55
|
+
version: '0'
|
|
56
56
|
- !ruby/object:Gem::Dependency
|
|
57
57
|
name: easy_request
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
116
116
|
version: '0'
|
|
117
117
|
requirements: []
|
|
118
118
|
rubyforge_project:
|
|
119
|
-
rubygems_version: 2.
|
|
119
|
+
rubygems_version: 2.5.2
|
|
120
120
|
signing_key:
|
|
121
121
|
specification_version: 4
|
|
122
122
|
summary: Gema para API ComproPago
|