Class: CirroIO::Client::Gig

Inherits:
Base
  • Object
show all
Includes:
BulkActionHelper
Defined in:
lib/cirro_io/client/gig.rb

Instance Method Summary collapse

Methods included from BulkActionHelper

#format_to_dashed_keys

Methods inherited from Base

custom_connection, custom_post, #initialize, site=

Constructor Details

This class inherits a constructor from CirroIO::Client::Base

Instance Method Details

#bulk_archive_with(gig_results, gig_time_activities) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cirro_io/client/gig.rb', line 21

def bulk_archive_with(gig_results, gig_time_activities)
  payload = { data: { relationships: {} } }
  payload[:data][:relationships][:gig_results] = gig_results.map do |result|
    result.attributes.merge({ relationships: {
                              'app-worker': { data: result.app_worker.attributes },
                              'gig-task': { data: result.gig_task.attributes },
                            } })
  end
  payload[:data][:relationships][:gig_time_activities] = gig_time_activities.map do |activity|
    activity.attributes.merge({ relationships: { 'app-worker': { data: activity.app_worker.attributes } } })
  end

  response = self.class.custom_post("bulk/gigs/#{id}/archive", format_to_dashed_keys(payload))

  self.class.parser.parse(self.class, response).first
end

#bulk_create_with(worker_filter, gig_tasks) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/cirro_io/client/gig.rb', line 11

def bulk_create_with(worker_filter, gig_tasks)
  payload = { data: { attributes:, relationships: {} } }
  payload[:data][:relationships][:gig_tasks] = gig_tasks.map(&:attributes)
  payload[:data][:relationships][:worker_filter] = worker_filter.attributes

  response = self.class.custom_post('bulk/gigs', format_to_dashed_keys(payload))

  self.class.parser.parse(self.class, response).first
end