The Creatary Ruby gem
A Ruby wrapper for the Creatary REST APIs
Installation
gem install creatary-sdk
Documentation
How to Use
If you are using rails then:
- Add the creatary-sdk gem to your Gemfile
gem 'creatary-sdk'
- Create a creatary.yml file in config with following contents:
development: &defaults
consumer_key: # the consumer key generated in creatary.com for you application
consumer_secret: # the consumer secret generated in creatary.com for you application
consumer_handler: # the of the class that implements the creatary handler logic
test:
<<: *defaults
production:
<<: *defaults
- Add following route to your routes.rb
match '/creatary/(:string)' => Creatary::API # you can replace 'creatary' with any other namespace
- Implement the Creatary handler logic (e.g.: creatary_handler.rb in helpers)
class CreataryHandler
def (user, session)
# should return the URL to which Creatary should redirect
end
def denied(session)
# should return the URL to which Creatary should redirect
end
def receive_sms(from_user, to_app, body)
end
def lifecycle_notification(channel, invoker, reason, application_name, notification_type, access_tokens)
end
end
- The routes exposed by the gem in your rails application are:
/creatary/authorize # redirect to this one when you want to initiate the OAUTH authorization flow (pass ?subscription_tariff_name='' parameter to the redirect when performing subscription authorization OAUTH flow)
/creatary/receive_sms # use this one (complement to form absolute path) as SMS URL when registering your application in creatary.com
/creatary/oauth_callback # use this one (complement to form absolute path) as OAUTH callback URL when registering your application in creatary.com
/creatary/lifecycle_callback # use this one (complement to form absolute path) as subscriber lifecycle callback URL when registering your application in creatary.com