Class: MasonHubAPI::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/mason_hub_api/resource.rb

Direct Known Subclasses

CallbackResource, ReturnResource

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Resource

Returns a new instance of Resource.



10
11
12
# File 'lib/mason_hub_api/resource.rb', line 10

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/mason_hub_api/resource.rb', line 8

def client
  @client
end

Instance Method Details

#delete_request(url, body: {}, headers: {}) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/mason_hub_api/resource.rb', line 26

def delete_request(url, body: {}, headers: {})
  response = client.connection.delete(url) do |request|
    request.body = parse_body(body)
    request.headers = request.headers.merge(headers)
  end

  handle_response response
end

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



14
15
16
# File 'lib/mason_hub_api/resource.rb', line 14

def get_request(url, params: {}, headers: {})
  handle_response client.connection.get(url, params, headers)
end

#post_request(url, body:, headers: {}) ⇒ Object



18
19
20
# File 'lib/mason_hub_api/resource.rb', line 18

def post_request(url, body:, headers: {})
  handle_response client.connection.post(url, parse_body(body), headers)
end

#put_request(url, body:, headers: {}) ⇒ Object



22
23
24
# File 'lib/mason_hub_api/resource.rb', line 22

def put_request(url, body:, headers: {})
  handle_response client.connection.put(url, parse_body(body), headers)
end