Class: Io::Flow::V0::Models::GraphqlRequest

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 = {}) ⇒ GraphqlRequest

Returns a new instance of GraphqlRequest.



33066
33067
33068
33069
33070
33071
33072
33073
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33066

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :query], 'GraphqlRequest')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @query = HttpClient::Preconditions.assert_class('query', opts.delete(:query), String)
  @operation_name = (x = opts.delete(:operation_name); x.nil? ? nil : HttpClient::Preconditions.assert_class('operation_name', x, String))
  @variables = (x = opts.delete(:variables); x.nil? ? nil : HttpClient::Preconditions.assert_class('variables', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('variables', d[1], String); h })
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



33064
33065
33066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33064

def id
  @id
end

#operation_nameObject (readonly)

Returns the value of attribute operation_name.



33064
33065
33066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33064

def operation_name
  @operation_name
end

#queryObject (readonly)

Returns the value of attribute query.



33064
33065
33066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33064

def query
  @query
end

#variablesObject (readonly)

Returns the value of attribute variables.



33064
33065
33066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33064

def variables
  @variables
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



33079
33080
33081
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33079

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

#to_hashObject



33083
33084
33085
33086
33087
33088
33089
33090
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33083

def to_hash
  {
    :id => id,
    :query => query,
    :operation_name => operation_name,
    :variables => variables.nil? ? nil : variables
  }
end

#to_jsonObject



33075
33076
33077
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 33075

def to_json
  JSON.dump(to_hash)
end