Class: Merge::Accounting::VendorCreditLine

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

Overview

# The VendorCreditLine Object

### Description
The `VendorCreditLine` object is used to represent a vendor credit's line items.
### Usage Example
Fetch from the `GET VendorCredit` endpoint and view the vendor credit's line
items.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tracking_categories:, id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, net_amount: OMIT, tracking_category: OMIT, description: OMIT, account: OMIT, company: OMIT, exchange_rate: OMIT, remote_was_deleted: OMIT, additional_properties: nil) ⇒ Merge::Accounting::VendorCreditLine

Parameters:

  • id (String) (defaults to: OMIT)
  • remote_id (String) (defaults to: OMIT)

    The third-party API ID of the matching object.

  • created_at (DateTime) (defaults to: OMIT)

    The datetime that this object was created by Merge.

  • modified_at (DateTime) (defaults to: OMIT)

    The datetime that this object was modified by Merge.

  • net_amount (Float) (defaults to: OMIT)

    The full value of the credit.

  • tracking_category (String) (defaults to: OMIT)

    The line’s associated tracking category.

  • tracking_categories (Array<String>)

    The line’s associated tracking categories.

  • description (String) (defaults to: OMIT)

    The line’s description.

  • account (Merge::Accounting::VendorCreditLineAccount) (defaults to: OMIT)

    The line’s account.

  • company (String) (defaults to: OMIT)

    The company the line belongs to.

  • exchange_rate (String) (defaults to: OMIT)

    The vendor credit line item’s exchange rate.

  • remote_was_deleted (Boolean) (defaults to: OMIT)

    Indicates whether or not this object has been deleted in the third party platform.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 65

def initialize(tracking_categories:, id: OMIT, remote_id: OMIT, created_at: OMIT, modified_at: OMIT, net_amount: OMIT,
               tracking_category: OMIT, description: OMIT, account: OMIT, company: OMIT, exchange_rate: OMIT, remote_was_deleted: OMIT, additional_properties: nil)
  @id = id if id != OMIT
  @remote_id = remote_id if remote_id != OMIT
  @created_at = created_at if created_at != OMIT
  @modified_at = modified_at if modified_at != OMIT
  @net_amount = net_amount if net_amount != OMIT
  @tracking_category = tracking_category if tracking_category != OMIT
  @tracking_categories = tracking_categories
  @description = description if description != OMIT
  @account =  if  != OMIT
  @company = company if company != OMIT
  @exchange_rate = exchange_rate if exchange_rate != OMIT
  @remote_was_deleted = remote_was_deleted if remote_was_deleted != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "remote_id": remote_id,
    "created_at": created_at,
    "modified_at": modified_at,
    "net_amount": net_amount,
    "tracking_category": tracking_category,
    "tracking_categories": tracking_categories,
    "description": description,
    "account": ,
    "company": company,
    "exchange_rate": exchange_rate,
    "remote_was_deleted": remote_was_deleted
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#accountMerge::Accounting::VendorCreditLineAccount (readonly)

Returns The line’s account.

Returns:



34
35
36
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 34

def 
  @account
end

#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/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 43

def additional_properties
  @additional_properties
end

#companyString (readonly)

Returns The company the line belongs to.

Returns:

  • (String)

    The company the line belongs to.



36
37
38
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 36

def company
  @company
end

#created_atDateTime (readonly)

Returns The datetime that this object was created by Merge.

Returns:

  • (DateTime)

    The datetime that this object was created by Merge.



22
23
24
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 22

def created_at
  @created_at
end

#descriptionString (readonly)

Returns The line’s description.

Returns:

  • (String)

    The line’s description.



32
33
34
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 32

def description
  @description
end

#exchange_rateString (readonly)

Returns The vendor credit line item’s exchange rate.

Returns:

  • (String)

    The vendor credit line item’s exchange rate.



38
39
40
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 38

def exchange_rate
  @exchange_rate
end

#idString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 18

def id
  @id
end

#modified_atDateTime (readonly)

Returns The datetime that this object was modified by Merge.

Returns:

  • (DateTime)

    The datetime that this object was modified by Merge.



24
25
26
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 24

def modified_at
  @modified_at
end

#net_amountFloat (readonly)

Returns The full value of the credit.

Returns:

  • (Float)

    The full value of the credit.



26
27
28
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 26

def net_amount
  @net_amount
end

#remote_idString (readonly)

Returns The third-party API ID of the matching object.

Returns:

  • (String)

    The third-party API ID of the matching object.



20
21
22
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 20

def remote_id
  @remote_id
end

#remote_was_deletedBoolean (readonly)

Returns Indicates whether or not this object has been deleted in the third party platform.

Returns:

  • (Boolean)

    Indicates whether or not this object has been deleted in the third party platform.



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

def remote_was_deleted
  @remote_was_deleted
end

#tracking_categoriesArray<String> (readonly)

Returns The line’s associated tracking categories.

Returns:

  • (Array<String>)

    The line’s associated tracking categories.



30
31
32
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 30

def tracking_categories
  @tracking_categories
end

#tracking_categoryString (readonly)

Returns The line’s associated tracking category.

Returns:

  • (String)

    The line’s associated tracking category.



28
29
30
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 28

def tracking_category
  @tracking_category
end

Class Method Details

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

Deserialize a JSON object to an instance of VendorCreditLine

Parameters:

  • json_object (String)

Returns:



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

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  remote_id = parsed_json["remote_id"]
  created_at = (DateTime.parse(parsed_json["created_at"]) unless parsed_json["created_at"].nil?)
  modified_at = (DateTime.parse(parsed_json["modified_at"]) unless parsed_json["modified_at"].nil?)
  net_amount = parsed_json["net_amount"]
  tracking_category = parsed_json["tracking_category"]
  tracking_categories = parsed_json["tracking_categories"]
  description = parsed_json["description"]
  if parsed_json["account"].nil?
     = nil
  else
     = parsed_json["account"].to_json
     = Merge::Accounting::VendorCreditLineAccount.from_json(json_object: )
  end
  company = parsed_json["company"]
  exchange_rate = parsed_json["exchange_rate"]
  remote_was_deleted = parsed_json["remote_was_deleted"]
  new(
    id: id,
    remote_id: remote_id,
    created_at: created_at,
    modified_at: modified_at,
    net_amount: net_amount,
    tracking_category: tracking_category,
    tracking_categories: tracking_categories,
    description: description,
    account: ,
    company: company,
    exchange_rate: exchange_rate,
    remote_was_deleted: remote_was_deleted,
    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)


152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 152

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.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_id is not the expected type, validation failed.")
  obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.modified_at&.is_a?(DateTime) != false || raise("Passed value for field obj.modified_at is not the expected type, validation failed.")
  obj.net_amount&.is_a?(Float) != false || raise("Passed value for field obj.net_amount is not the expected type, validation failed.")
  obj.tracking_category&.is_a?(String) != false || raise("Passed value for field obj.tracking_category is not the expected type, validation failed.")
  obj.tracking_categories.is_a?(Array) != false || raise("Passed value for field obj.tracking_categories 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..nil? || Merge::Accounting::VendorCreditLineAccount.validate_raw(obj: obj.)
  obj.company&.is_a?(String) != false || raise("Passed value for field obj.company is not the expected type, validation failed.")
  obj.exchange_rate&.is_a?(String) != false || raise("Passed value for field obj.exchange_rate is not the expected type, validation failed.")
  obj.remote_was_deleted&.is_a?(Boolean) != false || raise("Passed value for field obj.remote_was_deleted is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of VendorCreditLine to a JSON object

Returns:

  • (String)


142
143
144
# File 'lib/merge_ruby_client/accounting/types/vendor_credit_line.rb', line 142

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