Class: ProcessOut::SubmerchantMapping

Inherits:
Object
  • Object
show all
Defined in:
lib/processout/submerchant_mapping.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, data = {}) ⇒ SubmerchantMapping

Initializes the SubmerchantMapping object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



38
39
40
41
42
43
44
45
46
# File 'lib/processout/submerchant_mapping.rb', line 38

def initialize(client, data = {})
  @client = client

  self.submerchant_id = data.fetch(:submerchant_id, nil)
  self.gateway_configuration_id = data.fetch(:gateway_configuration_id, nil)
  self.psp_submerchant_id = data.fetch(:psp_submerchant_id, nil)
  self.created_at = data.fetch(:created_at, nil)
  
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



14
15
16
# File 'lib/processout/submerchant_mapping.rb', line 14

def created_at
  @created_at
end

#gateway_configuration_idObject

Returns the value of attribute gateway_configuration_id.



12
13
14
# File 'lib/processout/submerchant_mapping.rb', line 12

def gateway_configuration_id
  @gateway_configuration_id
end

#psp_submerchant_idObject

Returns the value of attribute psp_submerchant_id.



13
14
15
# File 'lib/processout/submerchant_mapping.rb', line 13

def psp_submerchant_id
  @psp_submerchant_id
end

#submerchant_idObject

Returns the value of attribute submerchant_id.



11
12
13
# File 'lib/processout/submerchant_mapping.rb', line 11

def submerchant_id
  @submerchant_id
end

Instance Method Details

#fill_with_data(data) ⇒ Object

Fills the object with data coming from the API Params:

data

Hash of data coming from the API



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/processout/submerchant_mapping.rb', line 66

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "submerchant_id"
    self.submerchant_id = data["submerchant_id"]
  end
  if data.include? "gateway_configuration_id"
    self.gateway_configuration_id = data["gateway_configuration_id"]
  end
  if data.include? "psp_submerchant_id"
    self.psp_submerchant_id = data["psp_submerchant_id"]
  end
  if data.include? "created_at"
    self.created_at = data["created_at"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new SubmerchantMapping using the current client



49
50
51
# File 'lib/processout/submerchant_mapping.rb', line 49

def new(data = {})
  SubmerchantMapping.new(@client, data)
end

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/processout/submerchant_mapping.rb', line 89

def prefill(data)
  if data.nil?
    return self
  end
  self.submerchant_id = data.fetch(:submerchant_id, self.submerchant_id)
  self.gateway_configuration_id = data.fetch(:gateway_configuration_id, self.gateway_configuration_id)
  self.psp_submerchant_id = data.fetch(:psp_submerchant_id, self.psp_submerchant_id)
  self.created_at = data.fetch(:created_at, self.created_at)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



54
55
56
57
58
59
60
61
# File 'lib/processout/submerchant_mapping.rb', line 54

def to_json(options)
  {
      "submerchant_id": self.submerchant_id,
      "gateway_configuration_id": self.gateway_configuration_id,
      "psp_submerchant_id": self.psp_submerchant_id,
      "created_at": self.created_at,
  }.to_json
end