Class: Merge::Accounting::PatchedItemRequestRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/accounting/types/patched_item_request_request.rb

Overview

# The Item Object

### Description
The `Item` object refers to the goods involved in a transaction.
### Usage Example
Fetch from the `LIST Items` endpoint and view a company's items.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: OMIT, status: OMIT, type: OMIT, unit_price: OMIT, purchase_price: OMIT, purchase_account: OMIT, sales_account: OMIT, company: OMIT, purchase_tax_rate: OMIT, sales_tax_rate: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Accounting::PatchedItemRequestRequest



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 74

def initialize(name: OMIT, status: OMIT, type: OMIT, unit_price: OMIT, purchase_price: OMIT,
               purchase_account: OMIT, sales_account: OMIT, company: OMIT, purchase_tax_rate: OMIT, sales_tax_rate: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil)
  @name = name if name != OMIT
  @status = status if status != OMIT
  @type = type if type != OMIT
  @unit_price = unit_price if unit_price != OMIT
  @purchase_price = purchase_price if purchase_price != OMIT
   =  if  != OMIT
   =  if  != OMIT
  @company = company if company != OMIT
  @purchase_tax_rate = purchase_tax_rate if purchase_tax_rate != OMIT
  @sales_tax_rate = sales_tax_rate if sales_tax_rate != OMIT
  @integration_params = integration_params if integration_params != OMIT
   =  if  != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "name": name,
    "status": status,
    "type": type,
    "unit_price": unit_price,
    "purchase_price": purchase_price,
    "purchase_account": ,
    "sales_account": ,
    "company": company,
    "purchase_tax_rate": purchase_tax_rate,
    "sales_tax_rate": sales_tax_rate,
    "integration_params": integration_params,
    "linked_account_params": 
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



47
48
49
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 47

def additional_properties
  @additional_properties
end

#companyString (readonly)



37
38
39
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 37

def company
  @company
end

#integration_paramsHash{String => Object} (readonly)



43
44
45
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 43

def integration_params
  @integration_params
end

#linked_account_paramsHash{String => Object} (readonly)



45
46
47
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 45

def 
  
end

#nameString (readonly)



17
18
19
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 17

def name
  @name
end

#purchase_accountString (readonly)



33
34
35
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 33

def 
  
end

#purchase_priceFloat (readonly)



31
32
33
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 31

def purchase_price
  @purchase_price
end

#purchase_tax_rateString (readonly)



39
40
41
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 39

def purchase_tax_rate
  @purchase_tax_rate
end

#sales_accountString (readonly)



35
36
37
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 35

def 
  
end

#sales_tax_rateString (readonly)



41
42
43
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 41

def sales_tax_rate
  @sales_tax_rate
end

#statusMerge::Accounting::Status7D1Enum (readonly)



21
22
23
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 21

def status
  @status
end

#typeMerge::Accounting::Type2BbEnum (readonly)



27
28
29
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 27

def type
  @type
end

#unit_priceFloat (readonly)



29
30
31
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 29

def unit_price
  @unit_price
end

Class Method Details

.from_json(json_object:) ⇒ Merge::Accounting::PatchedItemRequestRequest

Deserialize a JSON object to an instance of PatchedItemRequestRequest



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
141
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 111

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  name = parsed_json["name"]
  status = parsed_json["status"]
  type = parsed_json["type"]
  unit_price = parsed_json["unit_price"]
  purchase_price = parsed_json["purchase_price"]
   = parsed_json["purchase_account"]
   = parsed_json["sales_account"]
  company = parsed_json["company"]
  purchase_tax_rate = parsed_json["purchase_tax_rate"]
  sales_tax_rate = parsed_json["sales_tax_rate"]
  integration_params = parsed_json["integration_params"]
   = parsed_json["linked_account_params"]
  new(
    name: name,
    status: status,
    type: type,
    unit_price: unit_price,
    purchase_price: purchase_price,
    purchase_account: ,
    sales_account: ,
    company: company,
    purchase_tax_rate: purchase_tax_rate,
    sales_tax_rate: sales_tax_rate,
    integration_params: integration_params,
    linked_account_params: ,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 156

def self.validate_raw(obj:)
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.status&.is_a?(Merge::Accounting::Status7D1Enum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.type&.is_a?(Merge::Accounting::Type2BbEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
  obj.unit_price&.is_a?(Float) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.")
  obj.purchase_price&.is_a?(Float) != false || raise("Passed value for field obj.purchase_price is not the expected type, validation failed.")
  obj.&.is_a?(String) != false || raise("Passed value for field obj.purchase_account is not the expected type, validation failed.")
  obj.&.is_a?(String) != false || raise("Passed value for field obj.sales_account is not the expected type, validation failed.")
  obj.company&.is_a?(String) != false || raise("Passed value for field obj.company is not the expected type, validation failed.")
  obj.purchase_tax_rate&.is_a?(String) != false || raise("Passed value for field obj.purchase_tax_rate is not the expected type, validation failed.")
  obj.sales_tax_rate&.is_a?(String) != false || raise("Passed value for field obj.sales_tax_rate is not the expected type, validation failed.")
  obj.integration_params&.is_a?(Hash) != false || raise("Passed value for field obj.integration_params is not the expected type, validation failed.")
  obj.&.is_a?(Hash) != false || raise("Passed value for field obj.linked_account_params is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PatchedItemRequestRequest to a JSON object



146
147
148
# File 'lib/merge_ruby_client/accounting/types/patched_item_request_request.rb', line 146

def to_json(*_args)
  @_field_set&.to_json
end