Class: MC2P::MC2PClient
- Inherits:
-
Object
- Object
- MC2P::MC2PClient
- Defined in:
- lib/mc2p.rb
Overview
MC2P - class used to manage the communication with MyChoice2Pay API
Instance Attribute Summary collapse
-
#api_request ⇒ Object
Returns the value of attribute api_request.
-
#coupon_resource ⇒ Object
Returns the value of attribute coupon_resource.
-
#currency_resource ⇒ Object
Returns the value of attribute currency_resource.
-
#gateway_resource ⇒ Object
Returns the value of attribute gateway_resource.
-
#pay_data_resource ⇒ Object
Returns the value of attribute pay_data_resource.
-
#plan_resource ⇒ Object
Returns the value of attribute plan_resource.
-
#product_resource ⇒ Object
Returns the value of attribute product_resource.
-
#sale_resource ⇒ Object
Returns the value of attribute sale_resource.
-
#shipping_resource ⇒ Object
Returns the value of attribute shipping_resource.
-
#subscription_resource ⇒ Object
Returns the value of attribute subscription_resource.
-
#tax_resource ⇒ Object
Returns the value of attribute tax_resource.
-
#transaction_resource ⇒ Object
Returns the value of attribute transaction_resource.
Instance Method Summary collapse
- #_wrapper(cls, resource, data) ⇒ Object
- #authorization(data) ⇒ Object
- #coupon(data) ⇒ Object
- #currency(data) ⇒ Object
- #gateway(data) ⇒ Object
-
#initialize(key, secret_key) ⇒ MC2PClient
constructor
- Initializes a resource Params:
api_request
- Api request used to make all the requests to the API
path
- Path used to make all the requests to the API
object_item_class
-
Object item class used to return values.
- Path used to make all the requests to the API
- Api request used to make all the requests to the API
- Initializes a resource Params:
- #notification_data(data) ⇒ Object
- #pay_data(data) ⇒ Object
- #plan(data) ⇒ Object
- #product(data) ⇒ Object
- #sale(data) ⇒ Object
- #shipping(data) ⇒ Object
- #subscription(data) ⇒ Object
- #tax(data) ⇒ Object
- #transaction(data) ⇒ Object
Constructor Details
#initialize(key, secret_key) ⇒ MC2PClient
Initializes a resource Params:
api_request
-
Api request used to make all the requests to the API
path
-
Path used to make all the requests to the API
object_item_class
-
Object item class used to return values
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mc2p.rb', line 35 def initialize(key, secret_key) @api_request = APIRequest.new(key, secret_key) @product_resource = ProductResource.new(@api_request, '/product/', Product) @plan_resource = PlanResource.new(@api_request, '/plan/', Plan) @tax_resource = TaxResource.new(@api_request, '/tax/', Tax) @shipping_resource = ShippingResource.new(@api_request, '/shipping/', Shipping) @coupon_resource = CouponResource.new(@api_request, '/coupon/', Coupon) @transaction_resource = TransactionResource.new(@api_request, '/transaction/', Transaction) @subscription_resource = SubscriptionResource.new(@api_request, '/subscription/', Subscription) @authorization_resource = AuthorizationResource.new(@api_request, '/authorization/', Authorization) @sale_resource = SaleResource.new(@api_request, '/sale/', Sale) @currency_resource = CurrencyResource.new(@api_request, '/currency/', Currency) @gateway_resource = GatewayResource.new(@api_request, '/gateway/', Gateway) @pay_data_resource = PayDataResource.new(@api_request, '/pay/', PayData) end |
Instance Attribute Details
#api_request ⇒ Object
Returns the value of attribute api_request.
16 17 18 |
# File 'lib/mc2p.rb', line 16 def api_request @api_request end |
#coupon_resource ⇒ Object
Returns the value of attribute coupon_resource.
22 23 24 |
# File 'lib/mc2p.rb', line 22 def coupon_resource @coupon_resource end |
#currency_resource ⇒ Object
Returns the value of attribute currency_resource.
26 27 28 |
# File 'lib/mc2p.rb', line 26 def currency_resource @currency_resource end |
#gateway_resource ⇒ Object
Returns the value of attribute gateway_resource.
27 28 29 |
# File 'lib/mc2p.rb', line 27 def gateway_resource @gateway_resource end |
#pay_data_resource ⇒ Object
Returns the value of attribute pay_data_resource.
28 29 30 |
# File 'lib/mc2p.rb', line 28 def pay_data_resource @pay_data_resource end |
#plan_resource ⇒ Object
Returns the value of attribute plan_resource.
19 20 21 |
# File 'lib/mc2p.rb', line 19 def plan_resource @plan_resource end |
#product_resource ⇒ Object
Returns the value of attribute product_resource.
18 19 20 |
# File 'lib/mc2p.rb', line 18 def product_resource @product_resource end |
#sale_resource ⇒ Object
Returns the value of attribute sale_resource.
25 26 27 |
# File 'lib/mc2p.rb', line 25 def sale_resource @sale_resource end |
#shipping_resource ⇒ Object
Returns the value of attribute shipping_resource.
21 22 23 |
# File 'lib/mc2p.rb', line 21 def shipping_resource @shipping_resource end |
#subscription_resource ⇒ Object
Returns the value of attribute subscription_resource.
24 25 26 |
# File 'lib/mc2p.rb', line 24 def subscription_resource @subscription_resource end |
#tax_resource ⇒ Object
Returns the value of attribute tax_resource.
20 21 22 |
# File 'lib/mc2p.rb', line 20 def tax_resource @tax_resource end |
#transaction_resource ⇒ Object
Returns the value of attribute transaction_resource.
23 24 25 |
# File 'lib/mc2p.rb', line 23 def transaction_resource @transaction_resource end |
Instance Method Details
#_wrapper(cls, resource, data) ⇒ Object
76 77 78 |
# File 'lib/mc2p.rb', line 76 def _wrapper(cls, resource, data) cls.new(data, resource) end |
#authorization(data) ⇒ Object
108 109 110 |
# File 'lib/mc2p.rb', line 108 def (data) _wrapper(Authorization, @authorization_resource, data) end |
#coupon(data) ⇒ Object
96 97 98 |
# File 'lib/mc2p.rb', line 96 def coupon(data) _wrapper(Coupon, @coupon_resource, data) end |
#currency(data) ⇒ Object
116 117 118 |
# File 'lib/mc2p.rb', line 116 def currency(data) _wrapper(Currency, @currency_resource, data) end |
#gateway(data) ⇒ Object
120 121 122 |
# File 'lib/mc2p.rb', line 120 def gateway(data) _wrapper(Gateway, @gateway_resource, data) end |
#notification_data(data) ⇒ Object
128 129 130 |
# File 'lib/mc2p.rb', line 128 def notification_data(data) NotificationData.new(data, self) end |
#pay_data(data) ⇒ Object
124 125 126 |
# File 'lib/mc2p.rb', line 124 def pay_data(data) _wrapper(PayData, @pay_data_resource, data) end |
#plan(data) ⇒ Object
84 85 86 |
# File 'lib/mc2p.rb', line 84 def plan(data) _wrapper(Plan, @plan_resource, data) end |
#product(data) ⇒ Object
80 81 82 |
# File 'lib/mc2p.rb', line 80 def product(data) _wrapper(Product, @product_resource, data) end |
#sale(data) ⇒ Object
112 113 114 |
# File 'lib/mc2p.rb', line 112 def sale(data) _wrapper(Sale, @sale_resource, data) end |
#shipping(data) ⇒ Object
92 93 94 |
# File 'lib/mc2p.rb', line 92 def shipping(data) _wrapper(Shipping, @shipping_resource, data) end |
#subscription(data) ⇒ Object
104 105 106 |
# File 'lib/mc2p.rb', line 104 def subscription(data) _wrapper(Subscription, @subscription_resource, data) end |
#tax(data) ⇒ Object
88 89 90 |
# File 'lib/mc2p.rb', line 88 def tax(data) _wrapper(Tax, @tax_resource, data) end |
#transaction(data) ⇒ Object
100 101 102 |
# File 'lib/mc2p.rb', line 100 def transaction(data) _wrapper(Transaction, @transaction_resource, data) end |