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.



33098
33099
33100
33101
33102
33103
33104
33105
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33098

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :request_id, :data], 'GraphqlResponse')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @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.



33096
33097
33098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33096

def data
  @data
end

#errorsObject (readonly)

Returns the value of attribute errors.



33096
33097
33098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33096

def errors
  @errors
end

#idObject (readonly)

Returns the value of attribute id.



33096
33097
33098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33096

def id
  @id
end

#request_idObject (readonly)

Returns the value of attribute request_id.



33096
33097
33098
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33096

def request_id
  @request_id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33111
33112
33113
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33111

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

#to_hashObject



33115
33116
33117
33118
33119
33120
33121
33122
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33115

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

#to_jsonObject



33107
33108
33109
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33107

def to_json
  JSON.dump(to_hash)
end