Sha256: 35e2407ed64af0a8edfaad978e96fac47d13dd1488c845c3b0807aadf471094e

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

module Gameball
  class Event
    def self.sendEvent(eventBody)
      # Validating keys in incoming body
      if(Gameball.api_version=="v3.0")
        Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["mobile","email"])
      else
        Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["playerAttributes"])
      end
      res = Gameball::Utils::request("post", "/integrations/event", eventBody)
      # Check for HTTP Success and throws error if not success
      unless res.kind_of? Net::HTTPSuccess
        if res.kind_of? Net::HTTPInternalServerError
          raise Gameball::GameballError.new("An Internal Server Error has occurred")
        else
          raise Gameball::GameballError.new(res.body) 
        end
      else
        return true
      end
    end
    def self.sendEvent_async(eventBody)
      # Validating keys in incoming body
      Gameball::Utils.validate(eventBody, ["events", "playerUniqueId"], ["playerAttributes"])
      res = Gameball::Utils::request_async("post", "/integrations/event", eventBody)
      # Check for HTTP Success and throws error if not success
      unless res.kind_of? Net::HTTPSuccess
        if res.kind_of? Net::HTTPInternalServerError
          raise Gameball::GameballError.new("An Internal Server Error has occurred")
        else
          raise Gameball::GameballError.new(res.body) 
        end
      else
        return true
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gameball-3.1.5 lib/gameball/models/event.rb
gameball-3.1.4 lib/gameball/models/event.rb
gameball-2.1.4 lib/gameball/models/event.rb
gameball-2.1.3 lib/gameball/models/event.rb
gameball-2.1.1 lib/gameball/models/event.rb
gameball-2.0.1 lib/gameball/models/event.rb
gameball-2.0.0 lib/gameball/models/event.rb