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

Parameters:

  • name (String) (defaults to: OMIT)

    The item’s name.

  • status (Merge::Accounting::Status7D1Enum) (defaults to: OMIT)

    The item’s status.

    • ‘ACTIVE` - ACTIVE

    • ‘ARCHIVED` - ARCHIVED

  • type (Merge::Accounting::Type2BbEnum) (defaults to: OMIT)

    The item’s type.

    • ‘INVENTORY` - INVENTORY

    • ‘NON_INVENTORY` - NON_INVENTORY

    • ‘SERVICE` - SERVICE

    • ‘UNKNOWN` - UNKNOWN

  • unit_price (Float) (defaults to: OMIT)

    The item’s unit price.

  • purchase_price (Float) (defaults to: OMIT)

    The price at which the item is purchased from a vendor.

  • purchase_account (String) (defaults to: OMIT)

    References the default account used to record a purchase of the item.

  • sales_account (String) (defaults to: OMIT)

    References the default account used to record a sale.

  • company (String) (defaults to: OMIT)

    The company the item belongs to.

  • purchase_tax_rate (String) (defaults to: OMIT)

    The default purchase tax rate for this item.

  • sales_tax_rate (String) (defaults to: OMIT)

    The default sales tax rate for this item.

  • integration_params (Hash{String => Object}) (defaults to: OMIT)
  • linked_account_params (Hash{String => Object}) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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
  @purchase_account =  if  != OMIT
  @sales_account =  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
  @linked_account_params =  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)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



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)

Returns The company the item belongs to.

Returns:

  • (String)

    The company the item belongs to.



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)

Returns:

  • (Hash{String => Object})


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)

Returns:

  • (Hash{String => Object})


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

def 
  @linked_account_params
end

#nameString (readonly)

Returns The item’s name.

Returns:

  • (String)

    The item’s name.



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

def name
  @name
end

#purchase_accountString (readonly)

Returns References the default account used to record a purchase of the item.

Returns:

  • (String)

    References the default account used to record a purchase of the item.



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

def 
  @purchase_account
end

#purchase_priceFloat (readonly)

Returns The price at which the item is purchased from a vendor.

Returns:

  • (Float)

    The price at which the item is purchased from a vendor.



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)

Returns The default purchase tax rate for this item.

Returns:

  • (String)

    The default purchase tax rate for this item.



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)

Returns References the default account used to record a sale.

Returns:

  • (String)

    References the default account used to record a sale.



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

def 
  @sales_account
end

#sales_tax_rateString (readonly)

Returns The default sales tax rate for this item.

Returns:

  • (String)

    The default sales tax rate for this item.



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)

Returns The item’s status.

  • ‘ACTIVE` - ACTIVE

  • ‘ARCHIVED` - ARCHIVED.

Returns:



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)

Returns The item’s type.

  • ‘INVENTORY` - INVENTORY

  • ‘NON_INVENTORY` - NON_INVENTORY

  • ‘SERVICE` - SERVICE

  • ‘UNKNOWN` - UNKNOWN.

Returns:

  • (Merge::Accounting::Type2BbEnum)

    The item’s type.

    • ‘INVENTORY` - INVENTORY

    • ‘NON_INVENTORY` - NON_INVENTORY

    • ‘SERVICE` - SERVICE

    • ‘UNKNOWN` - UNKNOWN



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

def type
  @type
end

#unit_priceFloat (readonly)

Returns The item’s unit price.

Returns:

  • (Float)

    The item’s unit price.



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


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