Class: ComplyanceSDK::PurchaseInvoice::PurchaseInvoiceResult

Inherits:
Object
  • Object
show all
Defined in:
lib/complyance_sdk/purchase_invoice/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document_id:, client_id:, country:, environment:, document_number:, state:, is_terminal:, last_updated_at:, invoice:, xml:, xml_response:, artifacts:, government:, compliance:, errors:, validation_results:) ⇒ PurchaseInvoiceResult

Returns a new instance of PurchaseInvoiceResult.



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 169

def initialize(document_id:, client_id:, country:, environment:, document_number:, state:, is_terminal:,
               last_updated_at:, invoice:, xml:, xml_response:, artifacts:, government:, compliance:,
               errors:, validation_results:)
  @document_id = document_id
  @client_id = client_id
  @country = country
  @environment = environment
  @document_number = document_number
  @state = state
  @is_terminal = is_terminal
  @last_updated_at = last_updated_at
  @invoice = invoice
  @xml = xml
  @xml_response = xml_response
  @artifacts = artifacts
  @government = government
  @compliance = compliance
  @errors = errors || []
  @validation_results = validation_results
end

Instance Attribute Details

#artifactsObject (readonly)

Returns the value of attribute artifacts.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def artifacts
  @artifacts
end

#client_idObject (readonly)

Returns the value of attribute client_id.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def client_id
  @client_id
end

#complianceObject (readonly)

Returns the value of attribute compliance.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def compliance
  @compliance
end

#countryObject (readonly)

Returns the value of attribute country.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def country
  @country
end

#document_idObject (readonly)

Returns the value of attribute document_id.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def document_id
  @document_id
end

#document_numberObject (readonly)

Returns the value of attribute document_number.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def document_number
  @document_number
end

#environmentObject (readonly)

Returns the value of attribute environment.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def environment
  @environment
end

#errorsObject (readonly)

Returns the value of attribute errors.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def errors
  @errors
end

#governmentObject (readonly)

Returns the value of attribute government.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def government
  @government
end

#invoiceObject (readonly)

Returns the value of attribute invoice.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def invoice
  @invoice
end

#is_terminalObject (readonly)

Returns the value of attribute is_terminal.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def is_terminal
  @is_terminal
end

#last_updated_atObject (readonly)

Returns the value of attribute last_updated_at.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def last_updated_at
  @last_updated_at
end

#stateObject (readonly)

Returns the value of attribute state.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def state
  @state
end

#validation_resultsObject (readonly)

Returns the value of attribute validation_results.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def validation_results
  @validation_results
end

#xmlObject (readonly)

Returns the value of attribute xml.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def xml
  @xml
end

#xml_responseObject (readonly)

Returns the value of attribute xml_response.



152
153
154
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 152

def xml_response
  @xml_response
end

Class Method Details

.from_h(data) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/complyance_sdk/purchase_invoice/models.rb', line 190

def self.from_h(data)
  return nil unless data.is_a?(Hash)

  errors = Array(ModelHelpers.value_for(data, :errors)).filter_map do |entry|
    PurchaseInvoiceValidationErrorEntry.from_h(entry)
  end

  new(
    document_id: ModelHelpers.value_for(data, :documentId),
    client_id: ModelHelpers.value_for(data, :clientId),
    country: ModelHelpers.value_for(data, :country),
    environment: ModelHelpers.value_for(data, :environment),
    document_number: ModelHelpers.value_for(data, :documentNumber),
    state: ModelHelpers.value_for(data, :state),
    is_terminal: ModelHelpers.value_for(data, :isTerminal),
    last_updated_at: ModelHelpers.value_for(data, :lastUpdatedAt),
    invoice: ModelHelpers.value_for(data, :invoice),
    xml: ModelHelpers.value_for(data, :xml),
    xml_response: ModelHelpers.value_for(data, :xmlResponse),
    artifacts: PurchaseInvoiceArtifacts.from_h(ModelHelpers.value_for(data, :artifacts)),
    government: PurchaseInvoiceGovernmentStatus.from_h(ModelHelpers.value_for(data, :government)),
    compliance: PurchaseInvoiceCompliance.from_h(ModelHelpers.value_for(data, :compliance)),
    errors: errors,
    validation_results: PurchaseInvoiceValidationResults.from_h(ModelHelpers.value_for(data, :validationResults))
  )
end