Skip to content

rafaelpivato/shacip-ruby

Repository files navigation

Shacip Ruby Client

CircleCI Codacy Badge Codacy Badge

A client library for connecting with Shacip

Hypothesis

This is in early alpha stage. The idea is to be able to use it like seen in following sections.

Configuration

require 'shacip-client'

Shacip::Client.configure do |config|
  config.server_uri = 'http://localhost:3001'
  config.app_name = 'myapp.example.com'
end

Registration

include Shacip::Client

# Start by creating a registration object against Shacip
credentials = { email: 'john@example.com', 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

Authentication

include Shacip::Client

# We authenticate by creating an endorsement
credentials = { email: 'john@example.com', password: 'johndoe' }
endorsement = Endorsement.create(credentials)
if endorsement.recognized
  puts "Let the user sign in"
  user = endorsement.user
end

User Profile and Organization

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

About

A client library for connecting with Shacip (https://github.com/rafaelpivato/shacip)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages