Class: Tictail::Client

Inherits:
Object
  • Object
show all
Includes:
Api::Authenticate, Api::Card, Api::Customer, Api::Order, Api::Ping, Api::Product, Helper
Defined in:
lib/tictail/api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Api::Card

#post_card

Methods included from Api::Customer

#get_customer

Methods included from Api::Product

#get_products

Methods included from Api::Order

#get_orders

Methods included from Api::Ping

#ping

Methods included from Api::Authenticate

#authenticate

Methods included from Helper

#convert_hash_keys

Constructor Details

#initialize(url = 'https://api.tictail.com') ⇒ Client

Creates a new instance of Tictail::Api::Client

Parameters:

  • url (String) (defaults to: 'https://api.tictail.com')

    The url to Tictail api (api.tictail.com)



36
37
38
# File 'lib/tictail/api/client.rb', line 36

def initialize(url = 'https://api.tictail.com')
  @url = url
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



30
31
32
# File 'lib/tictail/api/client.rb', line 30

def access_token
  @access_token
end

Instance Method Details

#delete(url, params) ⇒ Object

Does a DELETE request to the url with the params

Parameters:

  • url (String)

    the relative path in the Tictail API



78
79
80
81
82
# File 'lib/tictail/api/client.rb', line 78

def delete(url, params)
  params = convert_hash_keys(params)
  @access_token = params.delete('access_token') if params['access_token']
  return connection.delete(url)
end

#get(url, params = {}) ⇒ Object

Does a GET request to the url with the params

Parameters:

  • url (String)

    the relative path in the Tictail API

  • params (Hash) (defaults to: {})

    the url params that should be passed in the request



46
47
48
49
50
# File 'lib/tictail/api/client.rb', line 46

def get(url, params = {})
  params = convert_hash_keys(params)
  @access_token = params.delete('access_token') if params['access_token']
  return connection.get(url, params)
end

#post(url, params) ⇒ Object

Does a POST request to the url with the params

Parameters:

  • url (String)

    the relative path in the Tictail API

  • params (Hash)

    the body of the request



57
58
59
60
61
# File 'lib/tictail/api/client.rb', line 57

def post(url, params)
  params = convert_hash_keys(params)
  @access_token = params.delete('access_token') if params['access_token']
  return connection.post(url, params)
end

#put(url, params) ⇒ Object

Does a PUT request to the url with the params

Parameters:

  • url (String)

    the relative path in the Tictail API

  • params (Hash)

    the body of the request



68
69
70
71
72
# File 'lib/tictail/api/client.rb', line 68

def put(url, params)
  params = convert_hash_keys(params)
  @access_token = params.delete('access_token') if params['access_token']
  return connection.put(url, params)
end