Module: FatZebra::APIOperation::Save::ClassMethods

Defined in:
lib/fat_zebra/api_operation/save.rb

Instance Method Summary collapse

Instance Method Details

#create(params = {}, options = {}) ⇒ FatZebra::Object

Create an API Resource and validate the params for the API.

Parameters:

  • params (Hash) (defaults to: {})

    for the request

  • Additional (Hash)

    options for the request

Returns:

  • (FatZebra::Object)

    response from the API



18
19
20
21
22
23
# File 'lib/fat_zebra/api_operation/save.rb', line 18

def create(params = {}, options = {})
  valid!(params, :create) if respond_to?(:valid!)

  response = request(:post, resource_path, params, options)
  initialize_from(response)
end

#update(id, params = {}, options = {}) ⇒ FatZebra::Object

Update an API Resource and validate params for the API

Parameters:

  • id (String)

    for the request

  • params (Hash) (defaults to: {})

    for the request

  • Additional (Hash)

    options for the request

Returns:

  • (FatZebra::Object)

    response from the API



33
34
35
36
37
38
# File 'lib/fat_zebra/api_operation/save.rb', line 33

def update(id, params = {}, options = {})
  valid!(params, :update) if respond_to?(:valid!)

  response = request(:put, "#{resource_path}/#{id}", params, options)
  initialize_from(response)
end