Skip to content

Commit 88d303e

Browse files
authored
Merge pull request #22 from compropago/staging
Staging
2 parents c77db03 + c33dbc2 commit 88d303e

11 files changed

Lines changed: 39 additions & 102 deletions

File tree

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,10 @@ providers = client.api.list_providers
231231
###### Prototipo del metodo get_providers()
232232

233233
```ruby
234-
# @param [Bolean] auth
235-
# @param [Float] limit
236-
# @param [Bolean] fetch
237-
# @return [Array]
238-
def list_providers(auth = false, limit = 0)
234+
# @param [float] limit
235+
# @param [string] currency
236+
# @return [array]
237+
def list_providers(limit = 0, currency = 'MXN')
239238
end
240239
```
241240

compropago_sdk.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Dir.glob('./lib/compropago_sdk/tools/*.rb').each do |archivo| li.push archivo en
1212

1313
Gem::Specification.new do |spec|
1414
spec.name = 'compropago_sdk'
15-
spec.version = '3.0.2'
15+
spec.version = '3.0.3'
1616
spec.authors = ['Eduardo Aguilar']
1717
spec.email = ['eduardo.aguilar@compropago.com']
1818

lib/compropago_sdk.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
require 'json'
55
require 'base64'
66

7-
require 'compropago_sdk/cp_config_sdk'
87
require 'compropago_sdk/client'
98
require 'compropago_sdk/service'
109

lib/compropago_sdk/client.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
class Client
22

3+
API_LIVE_URI = 'https://api.compropago.com/v1/'
4+
API_SANDBOX_URI = 'https://api.compropago.com/v1/'
5+
6+
VERSION = '3.0.3'
7+
38
attr_accessor :publickey, :privatekey, :live, :deploy_uri, :api
49

510
def initialize(publickey, privatekey, live)
@@ -8,9 +13,9 @@ def initialize(publickey, privatekey, live)
813
@live = live
914

1015
if live
11-
@deploy_uri = CpConfigSdk::API_LIVE_URI
16+
@deploy_uri = API_LIVE_URI
1217
else
13-
@deploy_uri = CpConfigSdk::API_SANDBOX_URI
18+
@deploy_uri = API_SANDBOX_URI
1419
end
1520

1621
@api = Service.new self

lib/compropago_sdk/cp_config_sdk.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.

lib/compropago_sdk/factory/models/place_order_info.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def initialize(
2323
expiration_time=nil,
2424
image_url='',
2525
app_client_name='sdk-ruby',
26-
app_client_version=CpConfigSdk::VERSION
26+
app_client_version=nil
2727
)
2828
@order_id = order_id
2929
@order_name = order_name
@@ -35,7 +35,12 @@ def initialize(
3535
@expiration_time = expiration_time
3636
@image_url = image_url
3737
@app_client_name = app_client_name
38-
@app_client_version = app_client_version
38+
39+
if app_client_version.nil?
40+
@app_client_version = Client::VERSION
41+
else
42+
@app_client_version = app_client_version
43+
end
3944
end
4045

4146
end

lib/compropago_sdk/factory/models/provider.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class Provider
22

33
attr_accessor :name
44
attr_accessor :store_image
5+
attr_accessor :availability
56
attr_accessor :is_active
67
attr_accessor :internal_name
78
attr_accessor :image_small

lib/compropago_sdk/factory/serialize.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def self.place_order_info(data=nil)
1515
data[:expiration_time] ? data[:expiration_time] : nil,
1616
data[:image_url] ? data[:image_url] : '',
1717
data[:app_client_name] ? data[:app_client_name] : 'sdk-ruby',
18-
data[:app_client_version] ? data[:app_client_version] : CpConfigSdk::VERSION,
18+
data[:app_client_version] ? data[:app_client_version] : Client::VERSION,
1919
)
2020
end
2121
end
@@ -192,6 +192,7 @@ def self.provider(data=nil)
192192

193193
obj.name = data['name']
194194
obj.store_image = data['store_image']
195+
obj.availability = data['availability']
195196
obj.is_active = data['is_active']
196197
obj.internal_name = data['internal_name']
197198
obj.image_small = data['image_small']

lib/compropago_sdk/service.rb

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ def initialize(client)
44
@client = client
55
end
66

7-
def list_providers(auth=false, limit=0, currency='MXN')
8-
if auth
9-
uri = @client.deploy_uri+'providers/'
10-
keys = {user: @client.get_user, pass: @client.get_pass}
11-
else
12-
uri = @client.deploy_uri+'providers/true/'
13-
keys = nil
14-
end
7+
def get_auth
8+
{ :user => @client.get_user, :pass => @client.get_pass }
9+
end
10+
11+
def list_providers(limit=0, currency='MXN')
12+
uri = @client.deploy_uri+'providers/'
1513

1614
if limit > 0
1715
uri = uri+'?order_total='+limit.to_s
@@ -21,16 +19,13 @@ def list_providers(auth=false, limit=0, currency='MXN')
2119
uri = uri+'&currency='+currency
2220
end
2321

24-
response = Request::get(uri, keys)
22+
response = Request::get(uri, get_auth)
2523

2624
Factory::get_instance_of 'ListProviders', response
2725
end
2826

2927
def verify_order(order_id)
30-
response = Request::get(
31-
@client.deploy_uri+'charges/'+order_id+'/',
32-
user: @client.get_user, pass: @client.get_pass
33-
)
28+
response = Request::get( @client.deploy_uri+'charges/'+order_id+'/', get_auth)
3429

3530
Factory::get_instance_of 'CpOrderInfo', response
3631
end
@@ -54,66 +49,43 @@ def place_order(order)
5449
:app_client_version => order.app_client_version
5550
}
5651

57-
response = Request::post(
58-
@client.deploy_uri+'charges/',
59-
params,
60-
user: @client.get_user, pass: @client.get_pass
61-
)
52+
response = Request::post(@client.deploy_uri+'charges/', params, get_auth)
6253

6354
Factory::get_instance_of 'NewOrderInfo', response
6455
end
6556

6657
def send_sms_instructions(number, order_id)
6758
params = {customer_phone: number}
6859

69-
response = Request::post(
70-
@client.deploy_uri+'charges/'+order_id+'/sms/',
71-
params,
72-
user: @client.get_user, pass: @client.get_pass
73-
)
60+
response = Request::post(@client.deploy_uri+'charges/'+order_id+'/sms/', params, get_auth)
7461

7562
Factory::get_instance_of 'SmsInfo', response
7663
end
7764

7865
def create_webhook(url)
7966
params = {url: url}
8067

81-
response = Request::post(
82-
@client.deploy_uri+'webhooks/stores/',
83-
params,
84-
user: @client.get_user, pass: @client.get_pass
85-
)
68+
response = Request::post(@client.deploy_uri+'webhooks/stores/', params, get_auth)
8669

8770
Factory::get_instance_of 'Webhook', response
8871
end
8972

9073
def update_webhook(webhook_id, new_url)
9174
params = {url: new_url}
9275

93-
response = Request::put(
94-
@client.deploy_uri+'webhooks/stores/'+webhook_id+'/',
95-
params,
96-
user: @client.get_user, pass: @client.get_pass
97-
)
76+
response = Request::put(@client.deploy_uri+'webhooks/stores/'+webhook_id+'/', params, get_auth)
9877

9978
Factory::get_instance_of 'Webhook', response
10079
end
10180

10281
def delete_webhook(webhook_id)
103-
response = Request::delete(
104-
@client.deploy_uri+'webhooks/stores/'+webhook_id,
105-
nil,
106-
user: @client.get_user, pass: @client.get_pass
107-
)
82+
response = Request::delete(@client.deploy_uri+'webhooks/stores/'+webhook_id, nil, get_auth)
10883

10984
Factory::get_instance_of 'Webhook', response
11085
end
11186

11287
def list_webhooks
113-
response = Request::get(
114-
@client.deploy_uri+'webhooks/stores/',
115-
user: @client.get_user, pass: @client.get_pass
116-
)
88+
response = Request::get(@client.deploy_uri+'webhooks/stores/', get_auth)
11789

11890
Factory::get_instance_of 'ListWebhooks', response
11991
end

lib/compropago_sdk/tools/http.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ def execute_request
6060

6161
if @auth && @auth.is_a?(Hash)
6262
req.basic_auth @auth[:user], @auth[:pass]
63-
#puts @auth.to_json
6463
end
6564

66-
#puts @data
67-
6865
req.body = @data
6966

7067
res = http.request(req)

0 commit comments

Comments
 (0)