Class: StrapiRuby::Client
- Inherits:
-
Object
- Object
- StrapiRuby::Client
- Defined in:
- lib/strapi_ruby/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #delete(endpoint) ⇒ Object
- #get(endpoint) ⇒ Object
-
#initialize(options = {}, &block) ⇒ Client
constructor
A new instance of Client.
- #post(endpoint, body) ⇒ Object
- #put(endpoint, body) ⇒ Object
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( = {}, &block) @connection = set_connection(, &block) end |
Instance Attribute Details
#connection ⇒ Object (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 |