rents 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e06c58eb1321502e8141b471a5aba0b782406cb4
4
- data.tar.gz: 338f971e9e496295b298b6178d801b37139c7d08
3
+ metadata.gz: f0fc5c6931a5592f03ae84ebffe92209de8ac213
4
+ data.tar.gz: 0c00189dfb43eaa7af06a0e7c77d6d840fd470ab
5
5
  SHA512:
6
- metadata.gz: 73c6a89696092ab521a65ffd26b054120748df24b49dd59d769a4b76146547ac58f7011eb7da059b7540194d47e87b7ff2a2610f6d724036416d26cc32413798
7
- data.tar.gz: 510f56ab6d54b8a9292743759ca2e6c4398da68866ffb0ca9dfea7c057e80e5457884c6f0ac60368fbec348ab40f1abefaa3d1a430d59ea25cc6e9dd204bae60
6
+ metadata.gz: dd42c1000b76dca1cea172603c83e3a4a1c3032e8e847368a4f97f272309e7a666cc99f77bca3d81dc34cdee18b7d7dc2ddd97ff100ef40ab8f09f3b28e896e9
7
+ data.tar.gz: b6e7b104b9420228868fd1d231aec649dba7d44258899415e632b6958d4e2e8c85262be595716e7d2ee66b0dc753eef7349529a484d0a5bbb8c85918ca4a5c80
data/.gitignore CHANGED
@@ -8,6 +8,7 @@ InstalledFiles
8
8
  _yardoc
9
9
  .idea/
10
10
  .idea/*
11
+ lib/rents/config/proxy.yml
11
12
  coverage
12
13
  coverage/
13
14
  coverage/*
data/Contributing.md ADDED
@@ -0,0 +1,203 @@
1
+ # API Routes
2
+ ![API Routes](https://raw.githubusercontent.com/PageRentS/rents-sdk-ruby/master/modeling/API%20Routes.png)
3
+
4
+ # Simple workflow overview
5
+
6
+ 1. Every class which consumes API must have the `Connection` class as parent
7
+ 2. `Connection` implement the HTTP RestClient methods
8
+ 3. Every message between the Developer app & the RentS framework must be a HashMap/Dictionary
9
+ 4. The object attrs are dynamic, based on the Hash received as constructor param
10
+ 5. Instantiation example
11
+ ```ruby
12
+ @transaction = Rents::Transaction.new({
13
+ card:{
14
+ brand: 'visa',
15
+ cvv: '123',
16
+ expiration_month: '05',
17
+ expiration_year: '2018',
18
+ number: '4012001037141112',
19
+ holder: Faker::Name.name,
20
+ },
21
+ recurrence_period_id: Rents.enum[:recurrence_periods][:daily],
22
+ amount: amount
23
+ })
24
+
25
+ # Charge
26
+ @resp = @transaction.charge_store
27
+
28
+ # same as
29
+ @transaction.charge_store
30
+ @transaction.resp
31
+ ```
32
+ 6. The `charge_store` implementation:
33
+ ```ruby
34
+ def charge_store full_resp=false
35
+ # method which setup this attrs to HTTP param, like sold_items array to GET params
36
+ custom_http_params
37
+
38
+ # dynamic path (the conection just read it path to send the HTTP request, so it is a config before perform)
39
+ self.path = 'transactions/store'
40
+
41
+ # full_resp = need the full HTTP Response (with code, headers...)
42
+ # if not full_resp return just Hash/Dictionary resp
43
+ full_resp ? self.resp = self.post_request : self.resp = self.post_json_request
44
+
45
+ # return it received resp
46
+ self.resp
47
+ end
48
+ ```
49
+ 7. It `Connection.new.post_request` implementation:
50
+
51
+ ```ruby
52
+ def post_request
53
+ # URL configured on the Connection child class method & the params received from the constructor
54
+ RestClient.post self.url_requested, self.request_params
55
+ end
56
+ ```
57
+ 8. It `Connection.new.post_json` implementation
58
+ ```ruby
59
+ resp = RestClient.post(self.url_requested, self.request_params)
60
+ to_hash_with_symbols(resp)
61
+
62
+ # Used on all the _json requests
63
+ def to_hash_with_symbols json
64
+ JSON.parse(json).it_keys_to_sym
65
+ end
66
+ ```
67
+
68
+
69
+ # What the user (developer) see
70
+
71
+ 1. A file which the developer config his environment:
72
+
73
+ ```ruby
74
+ # The RentS give to you 2 diferent apps, the production & the ratification (homolog) app
75
+ if developement_env || test_env
76
+ # Example using direct declaration (bad way, but must be possible)
77
+ Rents.app_id = 'YOUR_APP_ID'
78
+ Rents.secret_key = 'YOUR_APP_SECRET_KEY'
79
+
80
+ # TODO: Uncomment test_env if you want to test using RentS default_global app
81
+ # Rents.test_env = true
82
+
83
+ # TODO: Uncomment debugger if you have an RentS instance on your machine
84
+ # Rents.debug = true
85
+ else
86
+ # Production app
87
+ # Example using the secret config file
88
+ # REMEMBER to tell the client to not versioned those config files, like the SECRETs on the RAILS
89
+ # Extensions config files:
90
+ # (Ruby => .YML, PHP => .INI, JavaScript => JSON, ObjectiveC => .PLIST, C# => .DLL, Java => .XML)
91
+ Rents.app_id = Rails.application.secrets.rents['app_id']
92
+ Rents.secret_key = Rails.application.secrets.rents['app_id']
93
+ ```
94
+
95
+ 2. The Secret YML example
96
+
97
+ ```yml
98
+ production:
99
+ rents:
100
+ app_id: # TODO copy it from your PRODUCTION APP RentS page
101
+ app_secret_key: # TODO copy it from your PRODUCTION APP RentS page
102
+ ```
103
+
104
+ 3. ENUMs You can add ENUMs file or just get it from the API, but to improve the performance, create those files:
105
+ * Those [__files__](https://github.com/PageRentS/rents-sdk-ruby/tree/master/lib/rents/config/enums) are not visible to the Developer, but he can check if & easy access through a `Rents.enums`
106
+ * __`brands.yml`__
107
+ ```yml
108
+ brands:
109
+ # SampleObj
110
+ - id: 0
111
+ name: Nil
112
+ username: nil
113
+
114
+ # VISA
115
+ - id: 1
116
+ name: VISA
117
+ username: visa
118
+ ```
119
+ * __`currencies.yml`__
120
+ ```yml
121
+ currencies:
122
+ - id: 0
123
+ name: Nil
124
+ acronym: nil$
125
+ iso_code: NIL
126
+ iso_number: 000
127
+
128
+ # Real
129
+ - id: 1
130
+ name: Real
131
+ acronym: R$
132
+ iso_code: BRL
133
+ iso_number: 986
134
+ ```
135
+ * __`proxy.yml`__
136
+
137
+ ```yml
138
+ login: c1280361
139
+ password: 12345678
140
+ host: proxy.oranization.com
141
+ port: 80
142
+ ```
143
+
144
+ # How this work in the core
145
+ 1. The Rents is a Module/Namespace which have static methods (config), like:
146
+ * `bolean test_env`
147
+ * `bolean debug`
148
+ * `enum` (return a HashMap based on the config files: .ini, .yml, .xml, .plist...)
149
+ * `load_config_file` (return it file to the enum method: `load_yml`, `load_xml`, `load_ini`....)
150
+ * `proxy` (setup the proxy to the requests, useful for intranets & server apps in shared servers)
151
+
152
+ 2. `Connection.rb`, parent class for all API consumer classes, RestClient (GET, POST, PUT, DELETE)
153
+ * It must have both methods: `http_method_json` & `http_method`, `setup_default_app`
154
+ * `setup_default_app`: setup a `Rents.app_id` & `Rents.secret_key` & `this.recurrent_rid`
155
+ * `setup_default_app` also setup the auth: `this.auth = {app_id:Rents.app_id, secret_key:Rents.secret_key}`
156
+ * using actions: `this.path = 'global_app'` & `this.path = 'global_subscription'`
157
+ ```ruby
158
+ # SetUp a default app if Rents.test_env == true
159
+ def setup_default_app
160
+ # setup test_app path
161
+ self.path = 'global_app'
162
+
163
+ # Get the App & setup config
164
+ app = get_json_request[:app]
165
+ Rents.app_id = app[:id]
166
+ Rents.secret_key = app[:secret]
167
+
168
+ # Get the GlobalRecurrent & setup/config
169
+ self.path = 'global_subscription'
170
+ recurrence = get_json_request
171
+ self.recurrent_rid = recurrence[:rid]
172
+
173
+ return puts 'Please run: rails g rents:install' if Rents.app_id.nil? || Rents.secret_key.nil?
174
+ self.auth = {app_id:Rents.app_id, secret_key:Rents.secret_key}
175
+ self.request_params.merge!(auth:self.auth)
176
+ end
177
+ ```
178
+ * `http_method_json`: return a simple HashMap
179
+ * `http_method`: return the complet request resp, with code (200, 404, 403...)
180
+ * `setup_attrs(params)` params = constructor_params, it method iterate the hash attrs & set it as obj attr
181
+ ```ruby
182
+ # Dynamic attributtes
183
+ params.each do |key, value|
184
+ next unless key.to_s.index('[]').nil?
185
+ self.class.__send__(:attr_accessor, :"#{key}")
186
+ self.__send__("#{key}=", value)
187
+ end
188
+ ```
189
+ * Methods: `this.get_json`, `this.post_json`, `this.get`, `this.post`
190
+ * Attributtes (the first option is __`test_env`__ the second is production):
191
+ ```ruby
192
+ attr_accessor :auth = {app_id: '', app_secret: ''}
193
+ attr_accessor :path = ''
194
+ attr_accessor :domain = 'localhost:7000' || 'apprents.herokuapp.com'
195
+ attr_accessor :protocol = 'http' || 'https'
196
+ attr_accessor :end_point = this.protocol + "://" + this.domain + "api"
197
+ attr_accessor :api_version = 'v1'
198
+ attr_accessor :recurrent_rid = Rents.global_recurrence || rents_id,remote_id (rid)
199
+ attr_accessor :request_params = hash_received_on_constructor
200
+ attr_accessor :end_point_versioned = this.protocol + "://" + this.domain + "api" + this.api_version
201
+ ```
202
+
203
+
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
- source 'https://rubygems.org'
1
+ ruby '2.1.2'
2
2
  #ruby=2.1.2@rentsgem
3
+ source 'https://rubygems.org'
3
4
 
4
5
  # Specify your gem's dependencies in rents.gemspec
5
- gemspec
6
+ gemspec
data/README.md CHANGED
@@ -22,6 +22,7 @@ TODO: Write usage instructions here
22
22
 
23
23
  ## Contributing
24
24
 
25
+ 0. Check our [__Contributing MarkDown explanation__](https://github.com/PageRentS/rents-sdk-ruby/blob/master/Contributing.md)
25
26
  1. Fork it ( https://github.com/[my-github-username]/rents/fork )
26
27
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
28
  3. Commit your changes (`git commit -am 'Add some feature'`)
@@ -15,7 +15,7 @@ if Rails.env.development? || Rails.env.test?
15
15
  # TODO: Uncomment test_env if you want to test using RentS default & global app
16
16
  # Rents.test_env = true
17
17
  # TODO: Uncomment debugger if you have an RentS instance on your machine
18
- # Rents.debugger = true
18
+ # Rents.debug = true
19
19
  elsif Rails.env.production?
20
20
  # TODO if using Rails 3 or older, put here your PRODUCTION app_id & your secret_key
21
21
  Rents.app_id = ''
@@ -23,11 +23,11 @@ elsif Rails.env.production?
23
23
 
24
24
  # For production remember to keep it false or just remove it
25
25
  Rents.test_env = false
26
- Rents.debugger = false
26
+ Rents.debug = false
27
27
  end
28
28
 
29
29
  # Get your App config if your not using TEST_ENV nor DEBUGGER
30
- if (Rents.test_env.nil? && Rents.debugger.nil?) || (Rents.test_env == false && Rents.debugger == false)
30
+ if (Rents.test_env.nil? && Rents.debug.nil?) || (Rents.test_env == false && Rents.debug == false)
31
31
  if Rails.version[0].to_i >= 4
32
32
  Rents.app_id = Rails.application.secrets.rents['app_id']
33
33
  Rents.secret_key = Rails.application.secrets.rents['app_secret_key']
@@ -0,0 +1,6 @@
1
+ class Array
2
+ # Convert string keys to symbol keys
3
+ def it_keys_to_sym
4
+ self.each_with_index {|element, i| element.is_a?(Hash) ? self[i] = element.it_keys_to_sym : next }
5
+ end
6
+ end
@@ -0,0 +1,45 @@
1
+ brands:
2
+ # SampleObj
3
+ - id: 0
4
+ name: Nil
5
+ username: nil
6
+
7
+ # VISA
8
+ - id: 1
9
+ name: VISA
10
+ username: visa
11
+
12
+ # MasterCard
13
+ - id: 2
14
+ name: MasterCard
15
+ username: mastercard
16
+
17
+ # Diners Club
18
+ - id: 3
19
+ name: Diners Club
20
+ username: diners
21
+
22
+ # Discover
23
+ - id: 4
24
+ name: Discover
25
+ username: discover
26
+
27
+ # Elo
28
+ - id: 5
29
+ name: Elo
30
+ username: elo
31
+
32
+ # American Express
33
+ - id: 6
34
+ name: American Express
35
+ username: amex
36
+
37
+ # JCB
38
+ - id: 7
39
+ name: JCB
40
+ username: jcb
41
+
42
+ # Aura
43
+ - id: 8
44
+ name: Aura
45
+ username: aura
@@ -0,0 +1,35 @@
1
+ currencies:
2
+ # SampleObj
3
+ - id: 0
4
+ name: Nil
5
+ acronym: nil$
6
+ iso_code: NIL
7
+ iso_number: 000
8
+
9
+ # Real
10
+ - id: 1
11
+ name: Real
12
+ acronym: R$
13
+ iso_code: BRL
14
+ iso_number: 986
15
+
16
+ # Euro
17
+ - id: 2
18
+ name: Euro
19
+ acronym: €
20
+ iso_code: EUR
21
+ iso_number: 978
22
+
23
+ # US Dollar
24
+ - id: 3
25
+ name: US Dollar
26
+ acronym: US$
27
+ iso_code: USD
28
+ iso_number: 840
29
+
30
+ # CAD Dollar
31
+ - id: 4
32
+ name: CAD Dollar
33
+ acronym: CAD$
34
+ iso_code: CAD
35
+ iso_number: 124
@@ -0,0 +1,20 @@
1
+ payment_methods:
2
+ # SampleObj
3
+ - id: 0
4
+ name: Nil
5
+
6
+ # Credit
7
+ - id: 1
8
+ name: Credit
9
+
10
+ # Debit
11
+ - id: 2
12
+ name: Debit
13
+
14
+ # Installments shop
15
+ - id: 3
16
+ name: Installments shop
17
+
18
+ # Installments administrator
19
+ - id: 4
20
+ name: Installments administrator
@@ -0,0 +1,18 @@
1
+ recurrence_periods:
2
+ # Daily
3
+ daily: 1
4
+
5
+ # Weekly
6
+ weekly: 2
7
+
8
+ # Monthly
9
+ monthly: 3
10
+
11
+ # Bimonthly
12
+ bimonthly: 4
13
+
14
+ # Semiannual
15
+ semiannual: 5
16
+
17
+ # Annual
18
+ annual: 6
@@ -0,0 +1,31 @@
1
+ transaction_code:
2
+ 0:
3
+ status: pending
4
+ msg: Transação Criada
5
+ 1:
6
+ status: pending
7
+ msg: Transação em Andamento
8
+ 2:
9
+ status: pending
10
+ msg: Transação Autenticada
11
+ 3:
12
+ status: error
13
+ msg: Transação não Autenticada
14
+ 4:
15
+ status: pending
16
+ msg: Transação Autorizada
17
+ 5:
18
+ status: error
19
+ msg: Transação não Autorizada
20
+ 6:
21
+ status: charged
22
+ msg: Transação Capturada
23
+ 9:
24
+ status: error
25
+ msg: Transação Cancelada
26
+ 10:
27
+ status: pending
28
+ msg: Transação em Autenticação
29
+ 12:
30
+ status: pending
31
+ msg: Transação em Cancelamento
@@ -0,0 +1,4 @@
1
+ login: your_login
2
+ password: your_password
3
+ host: proxy_host
4
+ port: proxy_port
@@ -4,8 +4,10 @@ module Rents
4
4
  attr_accessor :auth
5
5
  attr_accessor :path
6
6
  attr_accessor :domain
7
+ attr_accessor :protocol
7
8
  attr_accessor :end_point
8
9
  attr_accessor :api_version
10
+ attr_accessor :recurrent_rid
9
11
  attr_accessor :request_params
10
12
  attr_accessor :end_point_versioned
11
13
 
@@ -13,20 +15,30 @@ module Rents
13
15
  def initialize(params = {})
14
16
  # An work around added to prevent a lot of changes
15
17
  params = params.merge({test_env:true}) if Rents.test_env
16
- params = params.merge({debugger:true}) if Rents.debugger
18
+ params = params.merge({debug:true}) if Rents.debug
17
19
 
18
20
  # Static part
19
21
  self.request_params = {transaction:params}
20
- setup_attrs(params)
21
22
  setup_config
22
23
  self.domain = 'apprents.herokuapp.com' # 'rents.pagerenter.com.br'
23
- self.domain = 'localhost:7000' if params[:debugger]
24
+
25
+ # If using test or Debug it is not production
26
+ if params[:debug] || params[:test]
27
+ self.protocol = 'http'
28
+ self.domain = 'localhost:7000'
29
+ else
30
+ self.protocol = 'https'
31
+ self.domain = 'apprents.herokuapp.com'
32
+ end
33
+
24
34
  self.api_version = 'v1'
25
- self.end_point = "http://#{self.domain}/api"
26
- self.end_point_versioned = "http://#{self.domain}/api/#{self.api_version}"
35
+ self.end_point = "#{self.protocol}://#{self.domain}/api"
36
+ self.end_point_versioned = "#{self.protocol}://#{self.domain}/api/#{self.api_version}"
27
37
 
28
38
  # Dynamic env
29
39
  setup_default_app if params[:test_env]
40
+ setup_attrs(params)
41
+ self.recurrent_rid = params[:rid] unless params[:rid].nil?
30
42
  end
31
43
 
32
44
  # Full URL for the last request
@@ -34,27 +46,54 @@ module Rents
34
46
  "#{self.end_point}/#{self.api_version}/#{self.path}"
35
47
  end
36
48
 
37
- # ============== HTTP REQUESTs METHODs ==============
38
- # GET
49
+ # GET http
39
50
  def get_request
40
51
  RestClient.get self.url_requested
41
52
  end
42
53
 
54
+ # GET json
43
55
  def get_json_request
44
- return JSON.parse(RestClient.get(self.url_requested)).it_keys_to_sym
56
+ resp = RestClient.get(self.url_requested)
57
+ to_hash_with_symbols(resp).it_keys_to_sym
45
58
  end
46
59
 
47
- # POST
60
+ # POST http
48
61
  def post_request
49
62
  RestClient.post self.url_requested, self.request_params
50
63
  end
51
64
 
65
+ # POST json
52
66
  def post_json_request
53
- return JSON.parse(RestClient.post(self.url_requested, self.request_params)).it_keys_to_sym
67
+ resp = RestClient.post(self.url_requested, self.request_params)
68
+ to_hash_with_symbols(resp)
69
+ end
70
+
71
+ # PUT http
72
+ def put_request
73
+ RestClient.put self.url_requested, self.request_params
74
+ end
75
+
76
+ # PUT json
77
+ def put_json_request
78
+ resp = RestClient.put(self.url_requested, self.request_params)
79
+ to_hash_with_symbols(resp)
80
+ end
81
+
82
+ # DELETE http
83
+ def delete_request
84
+ auth = self.request_params[:auth]
85
+ RestClient.delete self.url_requested, app_id:auth[:app_id], secret_key:auth[:secret_key]
86
+ end
87
+
88
+ # DELETE json
89
+ def delete_json_request
90
+ auth = self.request_params[:auth]
91
+ resp = RestClient.delete self.url_requested, auth_app_id:auth[:app_id], auth_secret_key:auth[:secret_key]
92
+ to_hash_with_symbols(resp)
54
93
  end
55
94
 
56
95
  # CALLBACKs
57
- private
96
+ protected
58
97
  # Config Attrs
59
98
  def setup_config
60
99
  self.auth = {app_id:Rents.app_id, secret_key:Rents.secret_key}
@@ -71,6 +110,11 @@ module Rents
71
110
  Rents.app_id = app[:id]
72
111
  Rents.secret_key = app[:secret]
73
112
 
113
+ # Get the GlobalRecurrent & setup/config
114
+ self.path = 'global_subscription'
115
+ recurrence = get_json_request
116
+ self.recurrent_rid = recurrence[:rid]
117
+
74
118
  return puts 'Please run: rails g rents:install' if Rents.app_id.nil? || Rents.secret_key.nil?
75
119
  self.auth = {app_id:Rents.app_id, secret_key:Rents.secret_key}
76
120
  self.request_params.merge!(auth:self.auth)
@@ -86,12 +130,43 @@ module Rents
86
130
  end
87
131
  end
88
132
 
89
- # HTTPs must have '[]' on it key name to send Array
133
+ # HTTP requests must have '[]' on it key name to send Array
90
134
  def custom_http_params
135
+ setup_format_and_validators
136
+
91
137
  return if self.sold_items.nil?
92
138
  self.sold_items.each_with_index do |sold_item, i|
93
139
  self.request_params[:transaction]["sold_items[#{i}]"] = sold_item
94
140
  end
95
141
  end
142
+
143
+ # Validate params to prevent errors like BAD Request & format values like value to Operator format
144
+ def setup_format_and_validators
145
+ validate_operator_format
146
+ end
147
+
148
+ # if necessary convert amount to operator value
149
+ def validate_operator_format
150
+ # prevent fatal error
151
+ return if self.amount.nil?
152
+
153
+ # aux vars
154
+ amount_str = self.amount.to_s
155
+ format_regex = /[.,]/
156
+
157
+ # if nil (it is not formatted, so it is not necessary to convert it format)
158
+ unless amount_str.match(format_regex).nil?
159
+ return if self.request_params.nil? || self.request_params[:transaction].nil?
160
+ self.amount = Rents::Currency.to_operator_str(self.amount)
161
+ self.request_params[:transaction][:amount] = self.amount
162
+ end
163
+ end
164
+
165
+ # Return the JSON in a Hash with it keys in symbols
166
+ def to_hash_with_symbols json
167
+ hashed = JSON.parse(json)
168
+ hashed.is_a?(Array) ? hashed.each_with_index { |hash, i| hashed[i] = hash.it_keys_to_sym } : hashed.it_keys_to_sym
169
+ hashed
170
+ end
96
171
  end
97
172
  end
@@ -45,21 +45,77 @@ module Rents
45
45
  self.resp
46
46
  end
47
47
 
48
- # TODO create charge works like a buy_store
49
48
  # POST /api/transactions
50
49
  def charge_store full_resp=false
51
50
  custom_http_params
52
51
 
53
52
  # dynamic path (it is written when a specific method use it)
54
- self.path = "transactions/store"
53
+ self.path = 'transactions/store'
55
54
 
56
55
  # using json_request because need only the answer (do not use something like it HTTP Code)
57
- self.resp = self.post_json_request unless full_resp
58
- self.resp = self.post_request if full_resp
56
+ full_resp ? self.resp = self.post_request : self.resp = self.post_json_request
57
+
58
+ # return it received resp
59
+ self.resp
60
+ end
61
+
62
+ # Update the recurrence amount
63
+ def update_subscription rid=nil, full_resp=false
64
+ # SetUp
65
+ self.recurrent_rid = rid if rid
66
+ self.path = "transactions/#{self.recurrent_rid}/subscription"
67
+
68
+ # Perform the request
69
+ full_resp ? self.resp = self.put_request : self.resp = self.put_json_request
70
+
71
+ # return it received resp
72
+ self.resp
73
+ end
74
+
75
+ # Stop a recurrence based on it transaction rid
76
+ def unsubscribe rid=nil, full_resp=false
77
+ # SetUp
78
+ self.recurrent_rid = rid if rid
79
+ self.path = "transactions/#{self.recurrent_rid}/subscription/unsubscribe"
80
+
81
+ # Perform the request
82
+ full_resp ? self.resp = self.delete_request : self.resp = self.delete_json_request
83
+
84
+ # return it received resp
85
+ self.resp
86
+ end
87
+
88
+ # Return the payments executed for the purchase passed
89
+ def payment_history rid=nil, full_resp=false
90
+ # SetUp
91
+ self.recurrent_rid = rid if rid
92
+ self.path = "transactions/#{self.recurrent_rid}/subscription/payment_history"
93
+ self.path = "#{self.path}#{self.request_params.it_keys_to_get_param}"
94
+
95
+ # Perform the request
96
+ full_resp ? self.resp = self.get_request : self.resp = self.get_json_request
97
+
98
+ # return it received resp
99
+ self.resp
100
+ end
101
+
102
+ # Check if a subscription is up-to-date or have any pending
103
+ def up_to_date rid=nil, full_resp=false
104
+ # SetUp
105
+ self.recurrent_rid = rid if rid
106
+
107
+ # Create/customize the path & add the auth as param
108
+ self.path = "transactions/#{self.recurrent_rid}/subscription/up-to-date"
109
+ self.path = "#{self.path}#{self.request_params.it_keys_to_get_param}"
110
+
111
+ # Perform the request
112
+ full_resp ? self.resp = self.get_request : self.resp = self.get_json_request
113
+
114
+ # return it received resp
59
115
  self.resp
60
116
  end
61
117
 
62
- # ================ STATICs ================
118
+ # ================ STATIC methods ================
63
119
  # GET /api/transactions/:rid by the rid passed
64
120
  def self.find rid
65
121
  end
data/lib/rents/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Rents
2
2
  MAJOR = 1
3
3
  MINOR = 0
4
- PATCH = 0
4
+ PATCH = 1
5
5
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
6
6
  end