Class: Ragoon::Services

Inherits:
Object
  • Object
show all
Defined in:
lib/ragoon/services.rb

Direct Known Subclasses

Notification, Schedule, Workflow

Defined Under Namespace

Classes: Notification, Schedule, Workflow

Constant Summary collapse

SERVICE_LOCATIONS =
{
  schedule:     '/cbpapi/schedule/api.csp?',
  notification: '/cbpapi/notification/api.csp?',
  workflow:     '/cbpapi/workflow/api.csp?',
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = Ragoon.secret_options) ⇒ Services

Returns a new instance of Services.



10
11
12
13
14
# File 'lib/ragoon/services.rb', line 10

def initialize(options = Ragoon.secret_options)
  @options = options
  @action_type = self.class.name.split('::').pop.downcase.to_sym
  @client = Ragoon::Client.new(self.endpoint, options)
end

Instance Attribute Details

#action_typeObject (readonly)

Returns the value of attribute action_type.



8
9
10
# File 'lib/ragoon/services.rb', line 8

def action_type
  @action_type
end

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/ragoon/services.rb', line 8

def client
  @client
end

Class Method Details

.start_and_end(date = Date.today) ⇒ Object



22
23
24
25
26
27
# File 'lib/ragoon/services.rb', line 22

def self.start_and_end(date = Date.today)
  {
    start: date.to_time.utc,
    end:   ((date + 1).to_time - 1).utc,
  }
end

Instance Method Details

#endpointObject



16
17
18
19
20
# File 'lib/ragoon/services.rb', line 16

def endpoint
  url = "#{base_endpoint}#{SERVICE_LOCATIONS[action_type]}"
  url.gsub!('.csp', '') if @options[:version].to_i == 3
  url
end

#garoon_endpointObject



29
30
31
# File 'lib/ragoon/services.rb', line 29

def garoon_endpoint
  base_endpoint
end