Class: Traktr::Account

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/traktr/account.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Account

Returns a new instance of Account.



6
7
8
# File 'lib/traktr/account.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#settingsObject

Raises:

  • (ResponseError)


10
11
12
13
14
15
16
# File 'lib/traktr/account.rb', line 10

def settings
  data = { username: @client.username, password: @client.password }
  response = self.class.post("/" + File.join("settings", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
  raise ResponseError.new(response) if response.code != 200

  Mash.new(response.parsed_response)
end

#testObject

Raises:

  • (ResponseError)


18
19
20
21
22
23
24
# File 'lib/traktr/account.rb', line 18

def test
  data = { username: @client.username, password: @client.password }
  response = self.class.post("/" + File.join("test", @client.api_key), body: data.to_json, headers: { 'Content-Type' => 'application/json'})
  raise ResponseError.new(response) if response.code != 200

  Mash.new(response.parsed_response)
end