Class: OrbipayPaymentsapiClient::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/orbipay_paymentsapi_client/wrappers/base.rb

Direct Known Subclasses

Customer, CustomerAccount, CustomerAccounts, Customers, FeePayment, FundingAccount, FundingAccounts, OrbipayPaymentsapiClientHandlers::AddFundingAccountHandler, OrbipayPaymentsapiClientHandlers::CreateCustomerHandler, OrbipayPaymentsapiClientHandlers::CreatePaymentHandler, OrbipayPaymentsapiClientHandlers::CreateRecurringPaymentSetupHandler, OrbipayPaymentsapiClientHandlers::CreateRefundHandler, OrbipayPaymentsapiClientHandlers::DeleteFundingAccountHandler, OrbipayPaymentsapiClientHandlers::DeletePaymentHandler, OrbipayPaymentsapiClientHandlers::DeletePaymentSetupHandler, OrbipayPaymentsapiClientHandlers::DeleteRecordPaymentHandler, OrbipayPaymentsapiClientHandlers::GetCustomerAccountHandler, OrbipayPaymentsapiClientHandlers::GetCustomerHandler, OrbipayPaymentsapiClientHandlers::GetFundingAccountHandler, OrbipayPaymentsapiClientHandlers::GetPaymentHandler, OrbipayPaymentsapiClientHandlers::GetPaymentSetupHandler, OrbipayPaymentsapiClientHandlers::GetRecordPaymentHandler, OrbipayPaymentsapiClientHandlers::GetRefundHandler, OrbipayPaymentsapiClientHandlers::RecordPaymentHandler, OrbipayPaymentsapiClientHandlers::RenewCustomerAccountHandler, OrbipayPaymentsapiClientHandlers::ReplaceFundingAccountHandler, OrbipayPaymentsapiClientHandlers::RetrieveCustomerAccountsHandler, OrbipayPaymentsapiClientHandlers::RetrieveCustomerAccountsPageHandler, OrbipayPaymentsapiClientHandlers::RetrieveCustomersHandler, OrbipayPaymentsapiClientHandlers::RetrieveCustomersPageHandler, OrbipayPaymentsapiClientHandlers::RetrieveFeePaymentHandler, OrbipayPaymentsapiClientHandlers::RetrieveFundingAccountsHandler, OrbipayPaymentsapiClientHandlers::RetrieveFundingAccountsPageHandler, OrbipayPaymentsapiClientHandlers::RetrievePaymentSetupsHandler, OrbipayPaymentsapiClientHandlers::RetrievePaymentsHandler, OrbipayPaymentsapiClientHandlers::RetrieveRecordPaymentsHandler, OrbipayPaymentsapiClientHandlers::RetrieveRefundsHandler, OrbipayPaymentsapiClientHandlers::SimplePaymentHandler, OrbipayPaymentsapiClientHandlers::UpdateCustomerHandler, OrbipayPaymentsapiClientHandlers::UpdateFundingAccountHandler, OrbipayPaymentsapiClientHandlers::UpdatePaymentHandler, OrbipayPaymentsapiClientHandlers::UpdatePaymentSetupHandler, Payment, PaymentSetup, PaymentSetups, Payments, RecordedPayment, RecordedPayments, Refund, Refunds, SimplePayment

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_end_point: nil, live_mode: nil, invocation_context: nil) ⇒ Base

Returns a new instance of Base.



46
47
48
49
50
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 46

def initialize(api_end_point: nil, live_mode: nil, invocation_context: nil)
	@api_end_point = api_end_point
	@live_mode = live_mode
	@invocation_context = invocation_context
end

Instance Attribute Details

#api_end_pointObject (readonly)

api_end_point of a call.



15
16
17
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 15

def api_end_point
  @api_end_point
end

#http_status_codeObject (readonly)

http_status_code of a call.



24
25
26
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 24

def http_status_code
  @http_status_code
end

#invocation_contextObject (readonly)

invocation_context of a call.



21
22
23
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 21

def invocation_context
  @invocation_context
end

#live_modeObject (readonly)

live_mode of a call.



18
19
20
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 18

def live_mode
  @live_mode
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



27
28
29
30
31
32
33
34
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 27

def self.attribute_map
  {
    :'api_end_point' => :'api_end_point',
    :'live_mode' => :'live_mode',
    :'invocation_context' => :'invocation_context',
    :'http_status_code' => :'http_status_code'
  }
end

.swagger_typesObject

Attribute type mapping.



37
38
39
40
41
42
43
44
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 37

def self.swagger_types
  {
    :'api_end_point' => :'String',
		:'live_mode' => :'String',
		:'invocation_context' => :'InvocationContext',
		:'http_status_code' => :'Integer'
  }
end

Instance Method Details

#for_client(client_key: nil) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 114

def for_client(client_key: nil)
	if @invocation_context.nil?
		@invocation_context = InvocationContext.new
	end
	@invocation_context.set_values(client_key: client_key)
	self
end

#requested_by(requestor: nil, requestor_type: nil) ⇒ Object



106
107
108
109
110
111
112
113
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 106

def requested_by(requestor: nil, requestor_type: nil)
	if @invocation_context.nil?
		@invocation_context = InvocationContext.new
	end
	@invocation_context.set_values(requestor: requestor)
	@invocation_context.set_values(requestor_type: requestor_type)
	self
end

#set_api_end_point(api_end_point: nil) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 52

def set_api_end_point(api_end_point: nil)
    if @live_mode == "true"
        @api_end_point = "https://api.orbipay.com/payments/v1"        
    elsif @live_mode == "false" && api_end_point.nil?
        @api_end_point = "https://sbapi.orbipay.com/payments/v1"
    elsif @live_mode == "false" && !api_end_point.nil?
        @api_end_point = api_end_point
    else
      if @live_mode.nil?
        OrbipayPaymentsapiClient.logger.error  "Invalid value for live_mode,  value Received in request : nil, valid values for live_mode: true, false"
        fail ApiError.new(:message => "Invalid value for live_mode,  value Received in request : nil, valid values for live_mode: true, false", :code => 0)
      else
        OrbipayPaymentsapiClient.logger.error "Invalid value for live_mode,  value Received in request : "+@live_mode+", valid values for live_mode: true, false"
        fail ApiError.new(:message => "Invalid value for live_mode,  value Received in request : "+@live_mode+", valid values for live_mode: true, false", :code => 0)
      end
    end
end

#set_values(args) ⇒ Object



122
123
124
125
126
127
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 122

def set_values(args)
  args.each do |attr, arg|
    (class << self; self; end).send(:attr_reader, attr.to_sym)
    instance_variable_set("@#{attr}", arg)
  end
end

#vide_channel(channel: nil) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 99

def vide_channel(channel: nil)
	if @invocation_context.nil?
		@invocation_context = InvocationContext.new
	end
	@invocation_context.set_values(channel: channel)
	self
end

#with_context(invocation_context, live_mode: nil, api_end_point: nil) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/orbipay_paymentsapi_client/wrappers/base.rb', line 70

def with_context(invocation_context, live_mode: nil, api_end_point: nil)
   @live_mode = live_mode
   set_api_end_point(api_end_point: api_end_point)
   if @invocation_context.nil?
       @invocation_context = InvocationContext()
   end
   if !invocation_context.product.nil?
       @invocation_context.set_values(product: invocation_context.product)
   end
   if !invocation_context.secret.nil?
       @invocation_context.set_values(secret: invocation_context.secret)
   end
   if !invocation_context.idempotent_request_key.nil?
       @invocation_context.set_values(idempotent_request_key: invocation_context.idempotent_request_key)
   end
   if !invocation_context.x_opay_headers.nil?
       @invocation_context.set_values(x_opay_headers: invocation_context.x_opay_headers)
   end
   if !invocation_context.api_key.nil?
       @invocation_context.set_values(api_key: invocation_context.api_key)
   end
   if !invocation_context.auth_scheme.nil?
       @invocation_context.set_values(auth_scheme: invocation_context.auth_scheme)
   end
   if !invocation_context.trace_id.nil?
       @invocation_context.set_values(trace_id: invocation_context.trace_id)
   end
end