compropago_sdk 3.0.2 → 3.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f6d2a2200fc271a002f255e02a65a633e261266
4
- data.tar.gz: 691d4df241474d65d0d69cd07ea2180e2b230ad9
3
+ metadata.gz: 9146fb6454176c0e98c84ecb623c2168871bf5ea
4
+ data.tar.gz: d77a7f88dcaaa7927b9368ff32df910a14f5806c
5
5
  SHA512:
6
- metadata.gz: 0e577bdb213201d1c1b7e86dcde25abff4bc7f0c477e2d6548dcd2327f60e79ed59db1fef8a2f0b8e7aa04ee87558f9f88f2981f554d3fd6d89d16ae497fd9dd
7
- data.tar.gz: 993dd3475311037a506a6be019b1d98b5097ae113fd4aef3fafb36488547cca4602fd993edf553eb1d4d1fd90c4c615987d7ff76fc1481c1bfda29a86b251594
6
+ metadata.gz: 90165947e6dc6898c2b83fafb30553c7d8281df4c0e48227aec0f8cb73898d519299132002b693f740a663a3fb6814a9e259e728af7d08d629f81db18d68bd39
7
+ data.tar.gz: 3778861eb921b422c0a91655c958d0aee4e41930ee408d574d543582df2193a36e1478c59c2bc52f7eb6206f80ed1063266f86c00e649f4971d009893af37edf
@@ -4,7 +4,6 @@ require 'net/http'
4
4
  require 'json'
5
5
  require 'base64'
6
6
 
7
- require 'compropago_sdk/cp_config_sdk'
8
7
  require 'compropago_sdk/client'
9
8
  require 'compropago_sdk/service'
10
9
 
@@ -1,5 +1,10 @@
1
1
  class Client
2
2
 
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
+
3
8
  attr_accessor :publickey, :privatekey, :live, :deploy_uri, :api
4
9
 
5
10
  def initialize(publickey, privatekey, live)
@@ -8,9 +13,9 @@ class Client
8
13
  @live = live
9
14
 
10
15
  if live
11
- @deploy_uri = CpConfigSdk::API_LIVE_URI
16
+ @deploy_uri = API_LIVE_URI
12
17
  else
13
- @deploy_uri = CpConfigSdk::API_SANDBOX_URI
18
+ @deploy_uri = API_SANDBOX_URI
14
19
  end
15
20
 
16
21
  @api = Service.new self
@@ -23,7 +23,7 @@ class PlaceOrderInfo
23
23
  expiration_time=nil,
24
24
  image_url='',
25
25
  app_client_name='sdk-ruby',
26
- app_client_version=CpConfigSdk::VERSION
26
+ app_client_version=nil
27
27
  )
28
28
  @order_id = order_id
29
29
  @order_name = order_name
@@ -35,7 +35,12 @@ class PlaceOrderInfo
35
35
  @expiration_time = expiration_time
36
36
  @image_url = image_url
37
37
  @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
39
44
  end
40
45
 
41
46
  end
@@ -2,6 +2,7 @@ class Provider
2
2
 
3
3
  attr_accessor :name
4
4
  attr_accessor :store_image
5
+ attr_accessor :availability
5
6
  attr_accessor :is_active
6
7
  attr_accessor :internal_name
7
8
  attr_accessor :image_small
@@ -15,7 +15,7 @@ class Serialize
15
15
  data[:expiration_time] ? data[:expiration_time] : nil,
16
16
  data[:image_url] ? data[:image_url] : '',
17
17
  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,
19
19
  )
20
20
  end
21
21
  end
@@ -192,6 +192,7 @@ class Serialize
192
192
 
193
193
  obj.name = data['name']
194
194
  obj.store_image = data['store_image']
195
+ obj.availability = data['availability']
195
196
  obj.is_active = data['is_active']
196
197
  obj.internal_name = data['internal_name']
197
198
  obj.image_small = data['image_small']
@@ -4,14 +4,12 @@ class Service
4
4
  @client = client
5
5
  end
6
6
 
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/'
15
13
 
16
14
  if limit > 0
17
15
  uri = uri+'?order_total='+limit.to_s
@@ -21,16 +19,13 @@ class Service
21
19
  uri = uri+'&currency='+currency
22
20
  end
23
21
 
24
- response = Request::get(uri, keys)
22
+ response = Request::get(uri, get_auth)
25
23
 
26
24
  Factory::get_instance_of 'ListProviders', response
27
25
  end
28
26
 
29
27
  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)
34
29
 
35
30
  Factory::get_instance_of 'CpOrderInfo', response
36
31
  end
@@ -54,11 +49,7 @@ class Service
54
49
  :app_client_version => order.app_client_version
55
50
  }
56
51
 
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)
62
53
 
63
54
  Factory::get_instance_of 'NewOrderInfo', response
64
55
  end
@@ -66,11 +57,7 @@ class Service
66
57
  def send_sms_instructions(number, order_id)
67
58
  params = {customer_phone: number}
68
59
 
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)
74
61
 
75
62
  Factory::get_instance_of 'SmsInfo', response
76
63
  end
@@ -78,11 +65,7 @@ class Service
78
65
  def create_webhook(url)
79
66
  params = {url: url}
80
67
 
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)
86
69
 
87
70
  Factory::get_instance_of 'Webhook', response
88
71
  end
@@ -90,30 +73,19 @@ class Service
90
73
  def update_webhook(webhook_id, new_url)
91
74
  params = {url: new_url}
92
75
 
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)
98
77
 
99
78
  Factory::get_instance_of 'Webhook', response
100
79
  end
101
80
 
102
81
  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)
108
83
 
109
84
  Factory::get_instance_of 'Webhook', response
110
85
  end
111
86
 
112
87
  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)
117
89
 
118
90
  Factory::get_instance_of 'ListWebhooks', response
119
91
  end
@@ -60,11 +60,8 @@ class Http
60
60
 
61
61
  if @auth && @auth.is_a?(Hash)
62
62
  req.basic_auth @auth[:user], @auth[:pass]
63
- #puts @auth.to_json
64
63
  end
65
64
 
66
- #puts @data
67
-
68
65
  req.body = @data
69
66
 
70
67
  res = http.request(req)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compropago_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Aguilar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-18 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,7 +61,6 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - "./lib/compropago_sdk.rb"
63
63
  - "./lib/compropago_sdk/client.rb"
64
- - "./lib/compropago_sdk/cp_config_sdk.rb"
65
64
  - "./lib/compropago_sdk/factory/factory.rb"
66
65
  - "./lib/compropago_sdk/factory/models/cp_order_info.rb"
67
66
  - "./lib/compropago_sdk/factory/models/customer.rb"
@@ -1,8 +0,0 @@
1
- module CpConfigSdk
2
-
3
- API_LIVE_URI = 'https://api.compropago.com/v1/'
4
- API_SANDBOX_URI = 'https://api.compropago.com/v1/'
5
-
6
- VERSION = '3.0.2'
7
-
8
- end