Class: Parse::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/adapters/parse/engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/adapters/parse/engine.rb', line 9

def initialize(data = {})
  @host     = data[:host] || Protocol::HOST
  @app_id   = data[:app_id]
  @api_key  = data[:api_key]
  @session  = Patron::Session.new
  @session.timeout = 10
  @session.connect_timeout = 10

  @session.base_url                 = "https://#{host}"
  @session.headers["Content-Type"]  = data[:content_type] || "application/json"
  @session.headers["Accept"]        = "application/json"
  @session.headers["User-Agent"]    = "Parse for Ruby, 0.0"
  @session.headers[Protocol::HEADER_APP_ID] = @app_id

  key_type = data[:master] ? Protocol::HEADER_MASTER_KEY : Protocol::HEADER_API_KEY
  @session.headers[key_type] = @api_key
end