Teachable

This gem is wrapper for the Teachable API

Installation

Add this line to your application's Gemfile:

gem 'teachable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install teachable

Usage

Register for the API

In order to use the gem, you first need to register an account with Teachable. You can register to the Teachable using this method call:

  Teachable::User.registration(email: '[email protected]', password: 'password', password_confirmation: 'password')

Authenticate for using API

If you are an already registered user, you need authenticate for using Teachable API. You can authenticate to the Teachable using this method call:

  Teachable::User.authenticate(email: '[email protected]', password: 'password')

Getting token

If you are an already registered user and you don't know or forgot your token, you can get it using this method call:

  Teachable::User.token(email: '[email protected]', password: 'password')

Configuration

You need to configure your 'user_email' and 'user_token'. In your Rails application you should add this code:

  Teachable.configure do |config|
    config.user_token = 'YOUR_API_TOKEN'
    config.user_email = '[email protected]'
  end

Getting User

If you are an already registered user and simply want to get information about you, you can simply use this method call:

  Teachable::User.get_user

Getting your orders

If you are an already registered user and simply want to get your orders, you can simply use this method call:

  Teachable::Order.orders

Creating order

If you are an already registered user and simply want to create order, you can simply use this method call:

  Teachable::Order.create(total: 3.0, total_quantity: 3, special_instructions: 'some description if needed')

Destroy order

If you are an already registered user and simply want to delete your order, you can simply use this method call:

  Teachable::Order.destroy(id: 1)

Development

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/teachable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.