Class: MasonHubAPI::CallbackResource
- Defined in:
- lib/mason_hub_api/resources/callback.rb
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
- #all(message_type: "all") ⇒ Object
- #create(attributes) ⇒ Object
-
#delete(callback_ids) ⇒ Response
Delete the registered callbacks.
Methods inherited from Resource
#delete_request, #get_request, #initialize, #post_request, #put_request
Constructor Details
This class inherits a constructor from MasonHubAPI::Resource
Instance Method Details
#all(message_type: "all") ⇒ Object
5 6 7 8 9 |
# File 'lib/mason_hub_api/resources/callback.rb', line 5 def all(message_type: "all") response = get_request("callbacks", params: { message_type: }) response.body.map { |attributes| Callback.new(attributes) } end |
#create(attributes) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/mason_hub_api/resources/callback.rb', line 11 def create(attributes) # accept either a single hash or an array of hashes attributes = [attributes] if attributes.is_a?(Hash) response = Response.new(post_request("callbacks", body: attributes).body) response.results = response.results.map { |callback| Callback.new(callback) } response end |
#delete(callback_ids) ⇒ Response
Delete the registered callbacks
27 28 29 30 31 32 |
# File 'lib/mason_hub_api/resources/callback.rb', line 27 def delete(callback_ids) callback_ids = [callback_ids] if callback_ids.is_a?(String) raise ArgumentError, "callback_ids must be an array or string" unless callback_ids.is_a?(Array) delete_request("callbacks", body: callback_ids).body end |