Class: Masheri::RpcClient

Inherits:
Object
  • Object
show all
Defined in:
lib/masheri/rpc_client.rb

Instance Method Summary collapse

Instance Method Details

#call_remote(method, opts = {}) ⇒ Object



103
104
105
# File 'lib/masheri/rpc_client.rb', line 103

def call_remote(method, opts = {})
  perform('method' => method, 'params' => Array(opts[:params]), 'id' => 1)
end

#configObject



79
80
81
# File 'lib/masheri/rpc_client.rb', line 79

def config
  Masheri.config
end

#create(type, params) ⇒ Object

Create an object



98
99
100
101
# File 'lib/masheri/rpc_client.rb', line 98

def create(type, params)
  # TODO: Handle params!
  call_remote [type_name, "create"].join('.')
end

#echo(value) ⇒ Object

Test Mashery API with echo service



84
85
86
# File 'lib/masheri/rpc_client.rb', line 84

def echo(value)
  call_remote('test.echo', value)
end

#full_urlObject Also known as: url



107
108
109
# File 'lib/masheri/rpc_client.rb', line 107

def full_url
  build_url(config.site_id, config.key, config.signature)
end

#query(string) ⇒ Object

Use the Mashery query language to grab data



93
94
95
# File 'lib/masheri/rpc_client.rb', line 93

def query(string)
  call_remote("object.query", params: string)
end

#query_builder(klass) ⇒ Object



88
89
90
# File 'lib/masheri/rpc_client.rb', line 88

def query_builder(klass)
  Masheri::QueryBuilder.new(klass)
end