Class: ProcessOut::NativeAPMTransactionDetails

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Initializes the NativeAPMTransactionDetails object Params:

client

ProcessOut client instance

data

data that can be used to fill the object



78
79
80
81
82
83
84
85
86
# File 'lib/processout/native_apm_transaction_details.rb', line 78

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

  self.gateway = data.fetch(:gateway, nil)
  self.invoice = data.fetch(:invoice, nil)
  self.parameters = data.fetch(:parameters, nil)
  self.state = data.fetch(:state, nil)
  
end

Instance Attribute Details

#gatewayObject

Returns the value of attribute gateway.



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

def gateway
  @gateway
end

#invoiceObject

Returns the value of attribute invoice.



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

def invoice
  @invoice
end

#parametersObject

Returns the value of attribute parameters.



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

def parameters
  @parameters
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
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



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/processout/native_apm_transaction_details.rb', line 106

def fill_with_data(data)
  if data.nil?
    return self
  end
  if data.include? "gateway"
    self.gateway = data["gateway"]
  end
  if data.include? "invoice"
    self.invoice = data["invoice"]
  end
  if data.include? "parameters"
    self.parameters = data["parameters"]
  end
  if data.include? "state"
    self.state = data["state"]
  end
  
  self
end

#new(data = {}) ⇒ Object

Create a new NativeAPMTransactionDetails using the current client



89
90
91
# File 'lib/processout/native_apm_transaction_details.rb', line 89

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

#prefill(data) ⇒ Object

Prefills the object with the data passed as parameters Params:

data

Hash of data



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/processout/native_apm_transaction_details.rb', line 129

def prefill(data)
  if data.nil?
    return self
  end
  self.gateway = data.fetch(:gateway, self.gateway)
  self.invoice = data.fetch(:invoice, self.invoice)
  self.parameters = data.fetch(:parameters, self.parameters)
  self.state = data.fetch(:state, self.state)
  
  self
end

#to_json(options) ⇒ Object

Overrides the JSON marshaller to only send the fields we want



94
95
96
97
98
99
100
101
# File 'lib/processout/native_apm_transaction_details.rb', line 94

def to_json(options)
  {
      "gateway": self.gateway,
      "invoice": self.invoice,
      "parameters": self.parameters,
      "state": self.state,
  }.to_json
end