Class: Rents::Transaction
- Inherits:
-
Connection
- Object
- Connection
- Rents::Transaction
- Defined in:
- lib/rents/transaction.rb
Overview
Transaction Obj, but can Abstract nested objs like Costumer
Instance Attribute Summary collapse
-
#resp ⇒ Object
Returns the value of attribute resp.
-
#sold_items ⇒ Object
Returns the value of attribute sold_items.
-
#status ⇒ Object
can be API Status: self.status = Rents::Status.new OR/AND Transaction Status.
Attributes inherited from Connection
#api_version, #auth, #domain, #end_point, #end_point_versioned, #path, #request_params
Class Method Summary collapse
-
.find(rid) ⇒ Object
STATICs ================ GET /api/transactions/:rid by the rid passed.
Instance Method Summary collapse
-
#charge_page(full_resp = false) ⇒ Object
POST /api/transactions/page return operator page URL, like the Cielo Page.
-
#initialize(params = {}) ⇒ Transaction
constructor
Constructor.
-
#rid ⇒ Object
Return it RID easily.
-
#verify ⇒ Object
GET /api/transactions/:rid by it attr.
Methods inherited from Connection
#get_json_request, #get_request, #post_json_request, #post_request, #url_requested
Constructor Details
#initialize(params = {}) ⇒ Transaction
Constructor
9 10 11 12 13 |
# File 'lib/rents/transaction.rb', line 9 def initialize(params = {}) super # super init call # Base redirect_link if test_env is set (so the redirect is just appended) self.redirect_link = "#{self.end_point_versioned}/transactions" if params[:test_env] end |
Instance Attribute Details
#resp ⇒ Object
Returns the value of attribute resp.
4 5 6 |
# File 'lib/rents/transaction.rb', line 4 def resp @resp end |
#sold_items ⇒ Object
Returns the value of attribute sold_items.
6 7 8 |
# File 'lib/rents/transaction.rb', line 6 def sold_items @sold_items end |
#status ⇒ Object
can be API Status: self.status = Rents::Status.new OR/AND Transaction Status
5 6 7 |
# File 'lib/rents/transaction.rb', line 5 def status @status end |
Class Method Details
.find(rid) ⇒ Object
STATICs ================
GET /api/transactions/:rid by the rid passed
54 55 |
# File 'lib/rents/transaction.rb', line 54 def self.find rid end |
Instance Method Details
#charge_page(full_resp = false) ⇒ Object
POST /api/transactions/page return operator page URL, like the Cielo Page
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rents/transaction.rb', line 29 def charge_page full_resp=false custom_http_params # SetUp redirect dynamic if is test self.request_params[:transaction][:redirect_link] = "#{self.redirect_link}/test" if self.request_params[:transaction][:test_env] # dynamic path (it is written when a specific method use it) self.path = "transactions/page" # using json_request because need only the answer (do not use something like it HTTP Code) self.resp = self.post_json_request unless full_resp self.resp = self.post_request if full_resp return self.resp end |
#rid ⇒ Object
Return it RID easily
16 17 18 |
# File 'lib/rents/transaction.rb', line 16 def rid self.resp[:rid] end |
#verify ⇒ Object
GET /api/transactions/:rid by it attr
21 22 23 24 25 26 |
# File 'lib/rents/transaction.rb', line 21 def verify auth_hash = {} auth_hash[:auth] = self.request_params[:auth] if self.rid.nil? then return {error:'RID not received'} else self.path = "transactions/#{self.rid}/#{auth_hash.it_keys_to_get_param}" end return self.get_json_request end |