A client library for connecting with Shacip
This is in early alpha stage. The idea is to be able to use it like seen in following sections.
require 'shacip-client'
Shacip::Client.configure do |config|
config.server_uri = 'http://localhost:3001'
config.app_name = 'myapp.example.com'
end
include Shacip::Client
# Start by creating a registration object against Shacip
credentials = { email: '[email protected]', password: 'johndoe' }
registration = Registration.create(credentials)
if registration.accepted
puts 'Send John a token with registration id'
registration_id = registration.id
else
raise StandarError, 'Registration not accepted'
end
# Optionally loads registration information
registration = Registration.load(registration_id)
puts "Email: #{registration.email}"
# Confirm registration by its identifier
registration = Registration.confirm(registration_id)
if registration.confirmed
puts "User #{registration.user.id} created at Shacip"
user = registration.user
organization = registration.organization
end
include Shacip::Client
# We authenticate by creating an endorsement
credentials = { email: '[email protected]', password: 'johndoe' }
endorsement = Endorsement.create(credentials)
if endorsement.recognized
puts "Let the user sign in"
user = endorsement.user
end
include Shacip::Client
user_id = 1234
user = User.load(user_id)
Organization.list(user).each do |org|
puts "Organization #{org.name}"
end
organization_id = 2345
organization = Organization.load(organization_id)
puts "Owner #{organization.owner.email}"
User.list(organization).each do |user|
puts "User #{user.email}"
end