Class: Ragoon::Services

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

Direct Known Subclasses

Notification, Schedule

Defined Under Namespace

Classes: Notification, Schedule

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeServices

Returns a new instance of Services.



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

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

Instance Attribute Details

#action_typeObject (readonly)

Returns the value of attribute action_type.



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

def action_type
  @action_type
end

#clientObject (readonly)

Returns the value of attribute client.



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

def client
  @client
end

Class Method Details

.start_and_end(date = Date.today) ⇒ Object



19
20
21
22
23
24
# File 'lib/ragoon/services.rb', line 19

def self.start_and_end(date = Date.today)
  {
    start: Time.local(date.year, date.month, date.day,     0).utc,
    end:   Time.local(date.year, date.month, date.day + 1, 0).utc,
  }
end

Instance Method Details

#endpointObject



14
15
16
17
# File 'lib/ragoon/services.rb', line 14

def endpoint
  endpoint = URI(Ragoon.garoon_endpoint)
  "#{endpoint.scheme}://#{endpoint.host}#{endpoint.path}#{SERVICE_LOCATIONS[action_type]}"
end