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.



34396
34397
34398
34399
34400
34401
34402
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34396

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:query], 'GraphqlRequest')
  @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

#operation_nameObject (readonly)

Returns the value of attribute operation_name.



34394
34395
34396
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34394

def operation_name
  @operation_name
end

#queryObject (readonly)

Returns the value of attribute query.



34394
34395
34396
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34394

def query
  @query
end

#variablesObject (readonly)

Returns the value of attribute variables.



34394
34395
34396
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34394

def variables
  @variables
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34408
34409
34410
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34408

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

#to_hashObject



34412
34413
34414
34415
34416
34417
34418
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34412

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

#to_jsonObject



34404
34405
34406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34404

def to_json
  JSON.dump(to_hash)
end