Class: Paid::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/paid_ruby/types/order.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: OMIT, name: OMIT, description: OMIT, customer_id: OMIT, organization_id: OMIT, start_date: OMIT, end_date: OMIT, total_amount: OMIT, estimated_tax: OMIT, billed_amount_no_tax: OMIT, billed_tax: OMIT, total_billed_amount: OMIT, pending_billing_amount: OMIT, creation_state: OMIT, order_lines: OMIT, customer: OMIT, additional_properties: nil) ⇒ Paid::Order

Parameters:

  • id (String) (defaults to: OMIT)
  • name (String) (defaults to: OMIT)
  • description (String) (defaults to: OMIT)
  • customer_id (String) (defaults to: OMIT)
  • organization_id (String) (defaults to: OMIT)
  • start_date (String) (defaults to: OMIT)
  • end_date (String) (defaults to: OMIT)
  • total_amount (Float) (defaults to: OMIT)
  • estimated_tax (Float) (defaults to: OMIT)
  • billed_amount_no_tax (Float) (defaults to: OMIT)
  • billed_tax (Float) (defaults to: OMIT)
  • total_billed_amount (Float) (defaults to: OMIT)
  • pending_billing_amount (Float) (defaults to: OMIT)
  • creation_state (Paid::CreationState) (defaults to: OMIT)
  • order_lines (Array<Paid::OrderLine>) (defaults to: OMIT)
  • customer (Paid::Customer) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/paid_ruby/types/order.rb', line 68

def initialize(id: OMIT, name: OMIT, description: OMIT, customer_id: OMIT, organization_id: OMIT, start_date: OMIT, end_date: OMIT, total_amount: OMIT, estimated_tax: OMIT, billed_amount_no_tax: OMIT, billed_tax: OMIT, total_billed_amount: OMIT, pending_billing_amount: OMIT, creation_state: OMIT, order_lines: OMIT, customer: OMIT, additional_properties: nil)
  @id = id if id != OMIT
  @name = name if name != OMIT
  @description = description if description != OMIT
  @customer_id = customer_id if customer_id != OMIT
  @organization_id = organization_id if organization_id != OMIT
  @start_date = start_date if start_date != OMIT
  @end_date = end_date if end_date != OMIT
  @total_amount = total_amount if total_amount != OMIT
  @estimated_tax = estimated_tax if estimated_tax != OMIT
  @billed_amount_no_tax = billed_amount_no_tax if billed_amount_no_tax != OMIT
  @billed_tax = billed_tax if billed_tax != OMIT
  @total_billed_amount = total_billed_amount if total_billed_amount != OMIT
  @pending_billing_amount = pending_billing_amount if pending_billing_amount != OMIT
  @creation_state = creation_state if creation_state != OMIT
  @order_lines = order_lines if order_lines != OMIT
  @customer = customer if customer != OMIT
  @additional_properties = additional_properties
  @_field_set = { "id": id, "name": name, "description": description, "customerId": customer_id, "organizationId": organization_id, "startDate": start_date, "endDate": end_date, "totalAmount": total_amount, "estimatedTax": estimated_tax, "billedAmountNoTax": billed_amount_no_tax, "billedTax": billed_tax, "totalBilledAmount": total_billed_amount, "pendingBillingAmount": pending_billing_amount, "creationState": creation_state, "orderLines": order_lines, "customer": customer }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



43
44
45
# File 'lib/paid_ruby/types/order.rb', line 43

def additional_properties
  @additional_properties
end

#billed_amount_no_taxFloat (readonly)

Returns:

  • (Float)


29
30
31
# File 'lib/paid_ruby/types/order.rb', line 29

def billed_amount_no_tax
  @billed_amount_no_tax
end

#billed_taxFloat (readonly)

Returns:

  • (Float)


31
32
33
# File 'lib/paid_ruby/types/order.rb', line 31

def billed_tax
  @billed_tax
end

#creation_statePaid::CreationState (readonly)

Returns:



37
38
39
# File 'lib/paid_ruby/types/order.rb', line 37

def creation_state
  @creation_state
end

#customerPaid::Customer (readonly)

Returns:



41
42
43
# File 'lib/paid_ruby/types/order.rb', line 41

def customer
  @customer
end

#customer_idString (readonly)

Returns:

  • (String)


17
18
19
# File 'lib/paid_ruby/types/order.rb', line 17

def customer_id
  @customer_id
end

#descriptionString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/paid_ruby/types/order.rb', line 15

def description
  @description
end

#end_dateString (readonly)

Returns:

  • (String)


23
24
25
# File 'lib/paid_ruby/types/order.rb', line 23

def end_date
  @end_date
end

#estimated_taxFloat (readonly)

Returns:

  • (Float)


27
28
29
# File 'lib/paid_ruby/types/order.rb', line 27

def estimated_tax
  @estimated_tax
end

#idString (readonly)

Returns:

  • (String)


11
12
13
# File 'lib/paid_ruby/types/order.rb', line 11

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/paid_ruby/types/order.rb', line 13

def name
  @name
end

#order_linesArray<Paid::OrderLine> (readonly)

Returns:



39
40
41
# File 'lib/paid_ruby/types/order.rb', line 39

def order_lines
  @order_lines
end

#organization_idString (readonly)

Returns:

  • (String)


19
20
21
# File 'lib/paid_ruby/types/order.rb', line 19

def organization_id
  @organization_id
end

#pending_billing_amountFloat (readonly)

Returns:

  • (Float)


35
36
37
# File 'lib/paid_ruby/types/order.rb', line 35

def pending_billing_amount
  @pending_billing_amount
end

#start_dateString (readonly)

Returns:

  • (String)


21
22
23
# File 'lib/paid_ruby/types/order.rb', line 21

def start_date
  @start_date
end

#total_amountFloat (readonly)

Returns:

  • (Float)


25
26
27
# File 'lib/paid_ruby/types/order.rb', line 25

def total_amount
  @total_amount
end

#total_billed_amountFloat (readonly)

Returns:

  • (Float)


33
34
35
# File 'lib/paid_ruby/types/order.rb', line 33

def total_billed_amount
  @total_billed_amount
end

Class Method Details

.from_json(json_object:) ⇒ Paid::Order

Parameters:

  • json_object (String)

Returns:



94
95
96
97
98
99
100
101
102
103
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/paid_ruby/types/order.rb', line 94

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  name = parsed_json["name"]
  description = parsed_json["description"]
  customer_id = parsed_json["customerId"]
  organization_id = parsed_json["organizationId"]
  start_date = parsed_json["startDate"]
  end_date = parsed_json["endDate"]
  total_amount = parsed_json["totalAmount"]
  estimated_tax = parsed_json["estimatedTax"]
  billed_amount_no_tax = parsed_json["billedAmountNoTax"]
  billed_tax = parsed_json["billedTax"]
  total_billed_amount = parsed_json["totalBilledAmount"]
  pending_billing_amount = parsed_json["pendingBillingAmount"]
  creation_state = parsed_json["creationState"]
  order_lines = parsed_json["orderLines"]&.map do | item |
  item = item.to_json
  Paid::OrderLine.from_json(json_object: item)
end
  unless parsed_json["customer"].nil?
    customer = parsed_json["customer"].to_json
    customer = Paid::Customer.from_json(json_object: customer)
  else
    customer = nil
  end
  new(
    id: id,
    name: name,
    description: description,
    customer_id: customer_id,
    organization_id: organization_id,
    start_date: start_date,
    end_date: end_date,
    total_amount: total_amount,
    estimated_tax: estimated_tax,
    billed_amount_no_tax: billed_amount_no_tax,
    billed_tax: billed_tax,
    total_billed_amount: total_billed_amount,
    pending_billing_amount: pending_billing_amount,
    creation_state: creation_state,
    order_lines: order_lines,
    customer: customer,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/paid_ruby/types/order.rb', line 153

def self.validate_raw(obj:)
  obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.customer_id&.is_a?(String) != false || raise("Passed value for field obj.customer_id is not the expected type, validation failed.")
  obj.organization_id&.is_a?(String) != false || raise("Passed value for field obj.organization_id is not the expected type, validation failed.")
  obj.start_date&.is_a?(String) != false || raise("Passed value for field obj.start_date is not the expected type, validation failed.")
  obj.end_date&.is_a?(String) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.")
  obj.total_amount&.is_a?(Float) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.")
  obj.estimated_tax&.is_a?(Float) != false || raise("Passed value for field obj.estimated_tax is not the expected type, validation failed.")
  obj.billed_amount_no_tax&.is_a?(Float) != false || raise("Passed value for field obj.billed_amount_no_tax is not the expected type, validation failed.")
  obj.billed_tax&.is_a?(Float) != false || raise("Passed value for field obj.billed_tax is not the expected type, validation failed.")
  obj.total_billed_amount&.is_a?(Float) != false || raise("Passed value for field obj.total_billed_amount is not the expected type, validation failed.")
  obj.pending_billing_amount&.is_a?(Float) != false || raise("Passed value for field obj.pending_billing_amount is not the expected type, validation failed.")
  obj.creation_state&.is_a?(Paid::CreationState) != false || raise("Passed value for field obj.creation_state is not the expected type, validation failed.")
  obj.order_lines&.is_a?(Array) != false || raise("Passed value for field obj.order_lines is not the expected type, validation failed.")
  obj.customer.nil? || Paid::Customer.validate_raw(obj: obj.customer)
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


144
145
146
# File 'lib/paid_ruby/types/order.rb', line 144

def to_json
  @_field_set&.to_json
end