Module: Giraffi::Client::Axions

Included in:
Giraffi::Client
Defined in:
lib/giraffi/client/axions.rb

Overview

Defines methods related to the axions

Instance Method Summary collapse

Instance Method Details

#add_medium_to_axion(*args) ⇒ HTTParty::Response

Adds a medium to the axion

Parameters:

  • args (Array)

    A set of params to add a medium to the axion

Options Hash (*args):

  • The (String)

    numerical ID of the related axion

  • The (String)

    numerical ID of the medium to add

Returns:

  • (HTTParty::Response)

Raises:

  • (ArgumentError)

Requires APIKEY?:

  • Yes



69
70
71
72
# File 'lib/giraffi/client/axions.rb', line 69

def add_medium_to_axion(*args)
  raise ArgumentError.new('The method `add_medium_to_axion` requires 2 argments (axion-id and medium-id)') if args.size != 2
  self.class.put("/axions/#{args[0]}/media/#{args[-1]}.json?apikey=#{apikey}", :body => {})
end

#create_axion(options = {}) ⇒ HTTParty::Response

Creates a new axion

Parameters:

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

    A set of attributes to create a new axion

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



39
40
41
# File 'lib/giraffi/client/axions.rb', line 39

def create_axion(options={})
  self.class.post("/axions.json?apikey=#{apikey}", :query => { :axion => options })
end

#destroy_axion(id) ⇒ HTTParty::Response

Deletes the axion

Parameters:

  • id (String)

    The numerical ID of the desired axion

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



79
80
81
# File 'lib/giraffi/client/axions.rb', line 79

def destroy_axion(id)
  self.class.delete("/axions/#{id}?apikey=#{apikey}")
end

#execute_axion(id) ⇒ HTTParty::Response

Executes the desired axion

Parameters:

  • id (String)

    The numerical ID of the desired axion

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



48
49
50
# File 'lib/giraffi/client/axions.rb', line 48

def execute_axion(id)
  self.class.post("/axions/#{id}/execute.json?apikey=#{apikey}")
end

#find_axion(id) ⇒ HTTParty::Response

Returns the desired axion

Parameters:

  • id (String)

    The numerical ID of the desired axion

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



20
21
22
# File 'lib/giraffi/client/axions.rb', line 20

def find_axion(id)
  self.class.get("/axions/#{id}.json?apikey=#{apikey}")
end

#find_axions(options = {}) ⇒ HTTParty::Response

Returns the desired axions

Parameters:

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

    The request params to retrieve the desired axions

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



11
12
13
# File 'lib/giraffi/client/axions.rb', line 11

def find_axions(options={})
  self.class.get("/axions.json?apikey=#{apikey}", :query => options)
end

#find_media_by_axion(id, options = {}) ⇒ HTTParty::Response

Returns all media related to the desired axion

Parameters:

  • id (String)

    The numerical ID of the desired axion

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

    A set of params to retrieve media related the axion

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



30
31
32
# File 'lib/giraffi/client/axions.rb', line 30

def find_media_by_axion(id, options={})
  self.class.get("/axions/#{id}/media.json?apikey=#{apikey}", :query => options)
end

#remove_medium_from_axion(*args) ⇒ HTTParty::Response

Removes a medium from the axion

Parameters:

  • args (Array)

    A set of params to remove a medium from the axion

Options Hash (*args):

  • The (String)

    numerical ID of the related axion

  • The (String)

    numerical ID of the axion to remove

Returns:

  • (HTTParty::Response)

Raises:

  • (ArgumentError)

Requires APIKEY?:

  • Yes



90
91
92
93
# File 'lib/giraffi/client/axions.rb', line 90

def remove_medium_from_axion(*args)
  raise ArgumentError.new('The method `remove_medium_from_axion` requires 2 argments (axion-id and medium-id)') if args.size != 2
  self.class.delete("/axions/#{args[0]}/media/#{args[-1]}.json?apikey=#{apikey}")
end

#update_axion(id, options = {}) ⇒ HTTParty::Response

Updates the desired axion

Parameters:

  • id (String)

    The numerical ID of the desired axion

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

    A set of attributes to update the axion

Returns:

  • (HTTParty::Response)

Requires APIKEY?:

  • Yes



58
59
60
# File 'lib/giraffi/client/axions.rb', line 58

def update_axion(id, options={})
  self.class.put("/axions/#{id}.json?apikey=#{apikey}", :query => { :axion => options }, :body => {})
end