Sha256: 6a97f294008faa8c810f488ed2a6c9f7d8c99fdce04bcf8faa7693bb2671b456

Contents?: true

Size: 791 Bytes

Versions: 1

Compression:

Stored size: 791 Bytes

Contents

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

  attr_reader :client, :action_type

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

  def endpoint
    "#{base_endpoint}#{SERVICE_LOCATIONS[action_type]}"
  end

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

  private

  def base_endpoint
    endpoint = URI(@options[:endpoint])
    "#{endpoint.scheme}://#{endpoint.host}#{endpoint.path}"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ragoon-0.6.0 lib/ragoon/services.rb