Sha256: f3f75323fbf5eec6a18926912c4d85c707c599bfb967f57f8bfe9a549a65a49f
Contents?: true
Size: 1.17 KB
Versions: 2
Compression:
Stored size: 1.17 KB
Contents
class Ragoon::Services SERVICE_LOCATIONS = { schedule: '/cbpapi/schedule/api.csp?', notification: '/cbpapi/notification/api.csp?', workflow: '/cbpapi/workflow/api.csp?', }.freeze attr_reader :client, :action_type 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 def endpoint url = "#{base_endpoint}#{SERVICE_LOCATIONS[action_type]}" url.gsub!('.csp', '') if @options[:version].to_i == 3 url end def self.start_and_end(date = Date.today) { start: date.to_time.utc, end: ((date + 1).to_time - 1).utc, } end def garoon_endpoint base_endpoint end private def base_endpoint endpoint = URI(@options[:endpoint]) "#{endpoint.scheme}://#{endpoint.host}#{endpoint.path}" end def parse_time(str) return nil if str.nil? Time.parse(str).localtime end def to_date_str(time) return nil if time.nil? time.localtime.strftime('%F') end def to_datetime_str(time) return nil if time.nil? time.utc.strftime('%FT%TZ') end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ragoon-1.1.1 | lib/ragoon/services.rb |
ragoon-1.1.0 | lib/ragoon/services.rb |