Class: Cloverrb::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/cloverrb/client.rb

Direct Known Subclasses

Address, Employee, LineItem, Merchant, Order, Properties

Constant Summary collapse

BASE_URL =
"https://api.clover.com/v3"
AUTH_URL =
"https://clover.com/oauth/token"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.generate_access_token(client_id, code, app_secret) ⇒ Object



26
27
28
29
# File 'lib/cloverrb/client.rb', line 26

def self.generate_access_token(client_id, code, app_secret)
  query = build_query(client_id, code, app_secret)
  HTTParty.get(AUTH_URL, query: query)
end

Instance Method Details

#get(token, path) ⇒ Object



6
7
8
# File 'lib/cloverrb/client.rb', line 6

def get(token, path)
  HTTParty.get(BASE_URL + path, headers: build_headers(token)).parsed_response
end

#post(token, path, body) ⇒ Object



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

def post(token, path, body)
  HTTParty.post(
    BASE_URL + path,
    headers: build_headers(token),
    query: body
  ).parsed_response
end

#put(token, path, body) ⇒ Object



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

def put(token, path, body)
  HTTParty.put(
    BASE_URL + path,
    headers: build_headers(token),
    query: body
  ).parsed_response
end