Class: Io::Flow::V0::Models::GraphqlResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ GraphqlResponse

Returns a new instance of GraphqlResponse.



33204
33205
33206
33207
33208
33209
33210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33204

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:request_id, :data], 'GraphqlResponse')
  @request_id = HttpClient::Preconditions.assert_class('request_id', opts.delete(:request_id), String)
  @data = HttpClient::Preconditions.assert_class('data', HttpClient::Helper.to_object(opts.delete(:data)), Hash)
  @errors = (x = opts.delete(:errors); x.nil? ? nil : HttpClient::Preconditions.assert_class('errors', x, Array).map { |v| HttpClient::Preconditions.assert_class('errors', HttpClient::Helper.to_object(v), Hash) })
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



33202
33203
33204
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33202

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



33202
33203
33204
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33202

def errors
  @errors
end

#request_idObject (readonly)

Returns the value of attribute request_id.



33202
33203
33204
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33202

def request_id
  @request_id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33216
33217
33218
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33216

def copy(incoming={})
  GraphqlResponse.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



33220
33221
33222
33223
33224
33225
33226
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33220

def to_hash
  {
    :request_id => request_id,
    :data => data,
    :errors => errors.nil? ? nil : errors
  }
end

#to_jsonObject



33212
33213
33214
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33212

def to_json
  JSON.dump(to_hash)
end