Class: Shipay::OrderCommom
- Inherits:
-
Model
- Object
- ShipayObject
- Model
- Shipay::OrderCommom
- Defined in:
- lib/shipay/order_commom.rb
Direct Known Subclasses
Constant Summary
Constants inherited from ShipayObject
Instance Attribute Summary
Attributes inherited from ShipayObject
Instance Method Summary collapse
-
#cancel ⇒ Order
Request order Cancel to Shipay api.
-
#primary_key ⇒ String
Defines primary key for model.
-
#refund(params = {}) ⇒ Order
Request refund to Shipay api for this order.
- #url_delete(*params) ⇒ Object
Methods inherited from Model
class_name, #class_name, #create, create, #fetch, find_by_id, #save, underscored_class_name, url, #url
Methods inherited from ShipayObject
#==, #[]=, convert, #empty?, #initialize, #respond_to?, #to_hash, #unsaved_attributes
Constructor Details
This class inherits a constructor from Shipay::ShipayObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Shipay::ShipayObject
Instance Method Details
#cancel ⇒ Order
Request order Cancel to Shipay api
39 40 41 42 |
# File 'lib/shipay/order_commom.rb', line 39 def cancel() update Shipay::Request.delete(url_delete, client_key: @client_key).call(underscored_class_name) self end |
#primary_key ⇒ String
Defines primary key for model
26 27 28 |
# File 'lib/shipay/order_commom.rb', line 26 def primary_key order_id end |
#refund(params = {}) ⇒ Order
Request refund to Shipay api for this order
16 17 18 19 20 |
# File 'lib/shipay/order_commom.rb', line 16 def refund(params={}) raise ParamError.new("Missing ammount param", :amount, :float, url('refund')) unless params.has_key? :amount update Shipay::Request.delete(url_delete('refund'), params: params.merge(client_key: @client_key)).call(underscored_class_name) self end |
#url_delete(*params) ⇒ Object
30 31 32 33 |
# File 'lib/shipay/order_commom.rb', line 30 def url_delete(*params) raise RequestError.new('Invalid ID') unless primary_key.present? ["/order", CGI.escape(primary_key.to_s), *params].join('/') end |