Class: Notisend::Client

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

Overview

Requests helper

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_token) ⇒ Client

Returns a new instance of Client.


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

def initialize(api_token)
  @api_token = api_token
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token


4
5
6
# File 'lib/notisend/client.rb', line 4

def api_token
  @api_token
end

Instance Method Details

#delete(path, params = {}) ⇒ Object


27
28
29
30
# File 'lib/notisend/client.rb', line 27

def delete(path, params = {})
  headers = prepare_headers
  make_request(method: :delete, path: path, params: params, headers: headers)
end

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


10
11
12
13
# File 'lib/notisend/client.rb', line 10

def get(path, params = {})
  headers = prepare_headers
  make_request(method: :get, path: path, params: params, headers: headers)
end

#patch(path, params = {}, files = {}) ⇒ Object


21
22
23
24
25
# File 'lib/notisend/client.rb', line 21

def patch(path, params = {}, files = {})
  body = prepare_body(params, files)
  headers = prepare_headers(files)
  make_request(method: :patch, path: path, headers: headers, body: body, multipart: multipart?(files))
end

#post(path, params = {}, files = {}) ⇒ Object


15
16
17
18
19
# File 'lib/notisend/client.rb', line 15

def post(path, params = {}, files = {})
  body = prepare_body(params, files)
  headers = prepare_headers(files)
  make_request(method: :post, path: path, headers: headers, body: body, multipart: multipart?(files))
end