Class: Flash::Integration::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/flash/integration/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url:, request_class: Faraday) ⇒ Connection

Returns a new instance of Connection.



8
9
10
11
# File 'lib/flash/integration/connection.rb', line 8

def initialize(base_url:, request_class: Faraday)
  @request_class = request_class
  @base_url = base_url
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



6
7
8
# File 'lib/flash/integration/connection.rb', line 6

def base_url
  @base_url
end

Instance Method Details

#default_headersObject



63
64
65
# File 'lib/flash/integration/connection.rb', line 63

def default_headers
  {}
end

#delete(url: "", params: {}, headers: {}, body: {}) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/flash/integration/connection.rb', line 53

def delete(url: "", params: {}, headers: {}, body: {})
  send_request(
    method: :delete,
    url: url,
    params: params,
    headers: headers,
    body: body
  )
end

#get(url: "", params: {}, headers: {}) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/flash/integration/connection.rb', line 13

def get(url: "", params: {}, headers: {})
  send_request(
    method: :get,
    url: url,
    params: params,
    headers: headers
  )
end

#patch(url: "", params: {}, headers: {}, body: {}) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/flash/integration/connection.rb', line 43

def patch(url: "", params: {}, headers: {}, body: {})
  send_request(
    method: :patch,
    url: url,
    params: params,
    headers: headers,
    body: body
  )
end

#post(url: "", params: {}, headers: {}, body: {}, multipart: false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/flash/integration/connection.rb', line 22

def post(url: "", params: {}, headers: {}, body: {}, multipart: false)
  send_request(
    method: :post,
    url: url,
    params: params,
    headers: headers,
    body: body,
    multipart: multipart
  )
end

#put(url: "", params: {}, headers: {}, body: {}) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/flash/integration/connection.rb', line 33

def put(url: "", params: {}, headers: {}, body: {})
  send_request(
    method: :put,
    url: url,
    params: params,
    headers: headers,
    body: body
  )
end