class Ragoon::Services

Constants

SERVICE_LOCATIONS

Attributes

action_type[R]
client[R]

Public Class Methods

new(options = Ragoon.secret_options) click to toggle source
# 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
start_and_end(date = Date.today) click to toggle source
# 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

Public Instance Methods

endpoint() click to toggle source
# 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_endpoint() click to toggle source
# File lib/ragoon/services.rb, line 29
def garoon_endpoint
  base_endpoint
end

Private Instance Methods

base_endpoint() click to toggle source
# File lib/ragoon/services.rb, line 35
def base_endpoint
  endpoint = URI(@options[:endpoint])
  "#{endpoint.scheme}://#{endpoint.host}#{endpoint.path}"
end
parse_time(str) click to toggle source
# File lib/ragoon/services.rb, line 40
def parse_time(str)
  return nil if str.nil?
  Time.parse(str).localtime
end
to_date_str(time) click to toggle source
# File lib/ragoon/services.rb, line 45
def to_date_str(time)
  return nil if time.nil?
  time.localtime.strftime('%F')
end
to_datetime_str(time) click to toggle source
# File lib/ragoon/services.rb, line 50
def to_datetime_str(time)
  return nil if time.nil?
  time.utc.strftime('%FT%TZ')
end