Created
July 3, 2015 21:29
-
-
Save Radagaisus/04a6664fafe6f6256549 to your computer and use it in GitHub Desktop.
Ruby, HTTParty, Captain Up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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