Class: Raas::OrderModel

Inherits:
BaseModel show all
Defined in:
lib/raas/models/order_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(account_identifier = nil, amount_charged = nil, created_at = nil, customer_identifier = nil, denomination = nil, reference_order_id = nil, reward = nil, reward_name = nil, send_email = nil, status = nil, utid = nil, campaign = nil, email_subject = nil, external_ref_id = nil, message = nil, notes = nil, recipient = nil, sender = nil) ⇒ OrderModel

Returns a new instance of OrderModel.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/raas/models/order_model.rb', line 104

def initialize( = nil,
               amount_charged = nil,
               created_at = nil,
               customer_identifier = nil,
               denomination = nil,
               reference_order_id = nil,
               reward = nil,
               reward_name = nil,
               send_email = nil,
               status = nil,
               utid = nil,
               campaign = nil,
               email_subject = nil,
               external_ref_id = nil,
               message = nil,
               notes = nil,
               recipient = nil,
               sender = nil)
  @account_identifier = 
  @amount_charged = amount_charged
  @created_at = created_at
  @customer_identifier = customer_identifier
  @denomination = denomination
  @reference_order_id = reference_order_id
  @reward = reward
  @reward_name = reward_name
  @send_email = send_email
  @status = status
  @utid = utid
  @campaign = campaign
  @email_subject = email_subject
  @external_ref_id = external_ref_id
  @message = message
  @notes = notes
  @recipient = recipient
  @sender = sender
end

Instance Attribute Details

#account_identifierString

Account Identifier

Returns:



8
9
10
# File 'lib/raas/models/order_model.rb', line 8

def 
  @account_identifier
end

#amount_chargedCurrencyBreakdownModel

Amount Charged



12
13
14
# File 'lib/raas/models/order_model.rb', line 12

def amount_charged
  @amount_charged
end

#campaignString

Campaign

Returns:



52
53
54
# File 'lib/raas/models/order_model.rb', line 52

def campaign
  @campaign
end

#created_atDateTime

Created At

Returns:

  • (DateTime)


16
17
18
# File 'lib/raas/models/order_model.rb', line 16

def created_at
  @created_at
end

#customer_identifierString

Customer Identifier

Returns:



20
21
22
# File 'lib/raas/models/order_model.rb', line 20

def customer_identifier
  @customer_identifier
end

#denominationCurrencyBreakdownModel

Denomination



24
25
26
# File 'lib/raas/models/order_model.rb', line 24

def denomination
  @denomination
end

#email_subjectString

Email Subject

Returns:



56
57
58
# File 'lib/raas/models/order_model.rb', line 56

def email_subject
  @email_subject
end

#external_ref_idString

External Reference ID

Returns:



60
61
62
# File 'lib/raas/models/order_model.rb', line 60

def external_ref_id
  @external_ref_id
end

#messageString

Message

Returns:



64
65
66
# File 'lib/raas/models/order_model.rb', line 64

def message
  @message
end

#notesString

Notes

Returns:



68
69
70
# File 'lib/raas/models/order_model.rb', line 68

def notes
  @notes
end

#recipientNameEmailModel

Recipient

Returns:



72
73
74
# File 'lib/raas/models/order_model.rb', line 72

def recipient
  @recipient
end

#reference_order_idString

Reference Order ID

Returns:



28
29
30
# File 'lib/raas/models/order_model.rb', line 28

def reference_order_id
  @reference_order_id
end

#rewardRewardModel

Reward

Returns:



32
33
34
# File 'lib/raas/models/order_model.rb', line 32

def reward
  @reward
end

#reward_nameString

Reward Name

Returns:



36
37
38
# File 'lib/raas/models/order_model.rb', line 36

def reward_name
  @reward_name
end

#send_emailBoolean

Send Email

Returns:

  • (Boolean)


40
41
42
# File 'lib/raas/models/order_model.rb', line 40

def send_email
  @send_email
end

#senderNameEmailModel

Sender

Returns:



76
77
78
# File 'lib/raas/models/order_model.rb', line 76

def sender
  @sender
end

#statusString

Status

Returns:



44
45
46
# File 'lib/raas/models/order_model.rb', line 44

def status
  @status
end

#utidString

UTID

Returns:



48
49
50
# File 'lib/raas/models/order_model.rb', line 48

def utid
  @utid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/raas/models/order_model.rb', line 143

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash
   = hash['accountIdentifier']
  amount_charged = CurrencyBreakdownModel.from_hash(hash['amountCharged']) if hash['amountCharged']
  created_at = DateTime.rfc3339(hash['createdAt']) if hash['createdAt']
  customer_identifier = hash['customerIdentifier']
  denomination = CurrencyBreakdownModel.from_hash(hash['denomination']) if hash['denomination']
  reference_order_id = hash['referenceOrderID']
  reward = RewardModel.from_hash(hash['reward']) if hash['reward']
  reward_name = hash['rewardName']
  send_email = hash['sendEmail']
  status = hash['status']
  utid = hash['utid']
  campaign = hash['campaign']
  email_subject = hash['emailSubject']
  external_ref_id = hash['externalRefID']
  message = hash['message']
  notes = hash['notes']
  recipient = NameEmailModel.from_hash(hash['recipient']) if hash['recipient']
  sender = NameEmailModel.from_hash(hash['sender']) if hash['sender']

  # Create object from extracted values
  OrderModel.new(,
                 amount_charged,
                 created_at,
                 customer_identifier,
                 denomination,
                 reference_order_id,
                 reward,
                 reward_name,
                 send_email,
                 status,
                 utid,
                 campaign,
                 email_subject,
                 external_ref_id,
                 message,
                 notes,
                 recipient,
                 sender)
end

.namesObject

A mapping from model property names to API property names



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/raas/models/order_model.rb', line 79

def self.names
  if @_hash.nil?
    @_hash = {}
    @_hash["account_identifier"] = "accountIdentifier"
    @_hash["amount_charged"] = "amountCharged"
    @_hash["created_at"] = "createdAt"
    @_hash["customer_identifier"] = "customerIdentifier"
    @_hash["denomination"] = "denomination"
    @_hash["reference_order_id"] = "referenceOrderID"
    @_hash["reward"] = "reward"
    @_hash["reward_name"] = "rewardName"
    @_hash["send_email"] = "sendEmail"
    @_hash["status"] = "status"
    @_hash["utid"] = "utid"
    @_hash["campaign"] = "campaign"
    @_hash["email_subject"] = "emailSubject"
    @_hash["external_ref_id"] = "externalRefID"
    @_hash["message"] = "message"
    @_hash["notes"] = "notes"
    @_hash["recipient"] = "recipient"
    @_hash["sender"] = "sender"
  end
  @_hash
end