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



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

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



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

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

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