Skip to content

Instantly share code, notes, and snippets.

@Radagaisus
Created July 3, 2015 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Radagaisus/04a6664fafe6f6256549 to your computer and use it in GitHub Desktop.
Save Radagaisus/04a6664fafe6f6256549 to your computer and use it in GitHub Desktop.
Ruby, HTTParty, Captain Up
class CaptainUp
# Include HTTParty as a mix-in
include HTTParty
# Set up the base API endpoint
base_uri 'captainup.com'
# Initialize the Captain Up SDK
def initialize(options = {})
@options = options
end
# Track and incentivize an action with Captain Up
def create_action(options = {})
# Send a POST request
self.class.post '/mechanics/v1/actions', query: {
# Your API key
app: @options[:api_key],
# Your API secret
secret: @options[:api_secret],
# The Captain Up user iD
user: options[:user_id],
# The action data
action: {
name: 'visit',
entity: {
type: 'page',
url: 'https://example.com/'
}
}
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment