Class: StrapiRuby::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ Client

Returns a new instance of Client.



8
9
10
# File 'lib/strapi_ruby/client.rb', line 8

def initialize(options = {}, &block)
  @connection = set_connection(options, &block)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



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

def connection
  @connection
end

Instance Method Details

#delete(endpoint) ⇒ Object



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

def delete(endpoint)
  response = performs_request { @connection.delete(endpoint) }
  handle_response(response)
end

#get(endpoint) ⇒ Object



12
13
14
15
# File 'lib/strapi_ruby/client.rb', line 12

def get(endpoint)
  response = performs_request { @connection.get(endpoint) }
  handle_response(response)
end

#post(endpoint, body) ⇒ Object



17
18
19
20
# File 'lib/strapi_ruby/client.rb', line 17

def post(endpoint, body)
  response = performs_request { @connection.post(endpoint, build_data_payload(body)) }
  handle_response(response)
end

#put(endpoint, body) ⇒ Object



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

def put(endpoint, body)
  response = performs_request { @connection.put(endpoint, build_data_payload(body)) }
  handle_response(response)
end