Sha256: 7bc278bc858296fd6fb150b8dbe8a5d4806d1d0b205ee966bfde7f8962108a44

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

module Cloudfuji
  class Expectation
    class << self
      def expectations_url
        "#{Cloudfuji::Platform.host}/apps/#{Cloudfuji::Platform.name}/expectations.json"
      end
      
      def create!(options={})
        # Enforce standard format on client side so that any errors
        # can be more quickly caught for the developer
        return StandardError("Cloudfuji::Event format incorrect, please make sure you're using the correct structure for sending events") unless !options[:criteria].nil? && !options[:expires_at].nil? && !options[:event].nil?
        return StandardError("Cloudfuji::Event format incorrect, please make sure you're using the correct structure for sending events") unless !options[:event][:category].nil? && !options[:event][:name].nil? && !options[:event][:data].nil?

        expectation                   = {}
        expectation[:criteria]        = options[:criteria]
        expectation[:expires_at]      = options[:expires_at]
        expectation[:event]           = options[:event]
        expectation[:parent_event_id] = options[:parent_event_id]

        payload = {:expectation => expectation}

        Cloudfuji::Command.post_command(expectations_url, payload)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloudfuji-0.0.46 lib/cloudfuji/expectation.rb
cloudfuji-0.0.45 lib/cloudfuji/expectation.rb