Class: NewStoreApi::SyncJobResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/sync_job_response.rb

Overview

Response model for synchronous job creation with immediate results.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(created_at = nil, data = nil, format = nil, job_id = nil, metadata = nil) ⇒ SyncJobResponse

Returns a new instance of SyncJobResponse.



54
55
56
57
58
59
60
61
# File 'lib/new_store_api/models/sync_job_response.rb', line 54

def initialize(created_at = nil, data = nil, format = nil, job_id = nil,
                = nil)
  @created_at = created_at
  @data = data
  @format = format
  @job_id = job_id
  @metadata = 
end

Instance Attribute Details

#created_atDateTime

Job creation timestamp (ISO 8601 format)

Returns:

  • (DateTime)


15
16
17
# File 'lib/new_store_api/models/sync_job_response.rb', line 15

def created_at
  @created_at
end

#dataArray[Object]

Query results data

Returns:

  • (Array[Object])


19
20
21
# File 'lib/new_store_api/models/sync_job_response.rb', line 19

def data
  @data
end

#formatString

Data format

Returns:

  • (String)


23
24
25
# File 'lib/new_store_api/models/sync_job_response.rb', line 23

def format
  @format
end

#job_idString

Unique job identifier

Returns:

  • (String)


27
28
29
# File 'lib/new_store_api/models/sync_job_response.rb', line 27

def job_id
  @job_id
end

#metadataObject

Job metadata including row_count, execution_time, and query_cost

Returns:

  • (Object)


31
32
33
# File 'lib/new_store_api/models/sync_job_response.rb', line 31

def 
  @metadata
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/new_store_api/models/sync_job_response.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  data = hash.key?('data') ? hash['data'] : nil
  format = hash.key?('format') ? hash['format'] : nil
  job_id = hash.key?('job_id') ? hash['job_id'] : nil
   = hash.key?('metadata') ? hash['metadata'] : nil

  # Create object from extracted values.
  SyncJobResponse.new(created_at,
                      data,
                      format,
                      job_id,
                      )
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/new_store_api/models/sync_job_response.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['created_at'] = 'created_at'
  @_hash['data'] = 'data'
  @_hash['format'] = 'format'
  @_hash['job_id'] = 'job_id'
  @_hash['metadata'] = 'metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/new_store_api/models/sync_job_response.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
# File 'lib/new_store_api/models/sync_job_response.rb', line 45

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (SyncJobResponse | Hash)

    value against the validation is performed.



90
91
92
93
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
# File 'lib/new_store_api/models/sync_job_response.rb', line 90

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.created_at,
                            ->(val) { val.instance_of? DateTime }) and
        APIHelper.valid_type?(value.data,
                              ->(val) { val.instance_of? Object }) and
        APIHelper.valid_type?(value.format,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.job_id,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.,
                              ->(val) { val.instance_of? Object })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['created_at'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['data'],
                            ->(val) { val.instance_of? Object }) and
      APIHelper.valid_type?(value['format'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['job_id'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['metadata'],
                            ->(val) { val.instance_of? Object })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



130
131
132
133
134
# File 'lib/new_store_api/models/sync_job_response.rb', line 130

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at.inspect}, data: #{@data.inspect}, format:"\
  " #{@format.inspect}, job_id: #{@job_id.inspect}, metadata: #{@metadata.inspect}>"
end

#to_custom_created_atObject



84
85
86
# File 'lib/new_store_api/models/sync_job_response.rb', line 84

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_sObject

Provides a human-readable string representation of the object.



123
124
125
126
127
# File 'lib/new_store_api/models/sync_job_response.rb', line 123

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at}, data: #{@data}, format: #{@format}, job_id:"\
  " #{@job_id}, metadata: #{@metadata}>"
end