teachable 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e14f8c36d3eaa0184bbf3d71b3656b85e3732c0
4
+ data.tar.gz: e9c65000993e9bed9a15354f75b068ef8e07fcc3
5
+ SHA512:
6
+ metadata.gz: 76da0a96cab342c6620d161c0e599aba9468000ed61b8a6a7663e7a858d85dcaee42fb6a25eaef921d45db1a448f71618a6805bf5b5d3b1012cbf10836260b2c
7
+ data.tar.gz: 40cdbf30171dd494ce75d8a27b1b01ebbbda803ea35ad9c8e5c3955112b87a3ca8466d729dfe3043a278147bdcb6d8e906e577379f43d0315e4afe6239383636
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ .rubocop.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at TODO: Write your email address. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,85 @@
1
+ # Teachable
2
+
3
+ This gem is wrapper for the Teachable API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'teachable'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install teachable
20
+
21
+ ## Usage
22
+
23
+ ### Register for the API
24
+ 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:
25
+ ```ruby
26
+ Teachable::User.registration(email: 'example@example.io', password: 'password', password_confirmation: 'password')
27
+ ```
28
+
29
+ ### Authenticate for using API
30
+ If you are an already registered user, you need authenticate for using Teachable API. You can authenticate to the Teachable using this method call:
31
+ ```ruby
32
+ Teachable::User.authenticate(email: 'example@example.io', password: 'password')
33
+ ```
34
+
35
+ ### Getting token
36
+ If you are an already registered user and you don't know or forgot your token, you can get it using this method call:
37
+ ```ruby
38
+ Teachable::User.token(email: 'example@example.io', password: 'password')
39
+ ```
40
+
41
+ ### Configuration
42
+ You need to configure your 'user_email' and 'user_token'. In your Rails application you should add this code:
43
+ ```ruby
44
+ Teachable.configure do |config|
45
+ config.user_token = 'YOUR_API_TOKEN'
46
+ config.user_email = 'example@example.io'
47
+ end
48
+ ```
49
+
50
+ ### Getting User
51
+ If you are an already registered user and simply want to get information about you, you can simply use this method call:
52
+ ```ruby
53
+ Teachable::User.get_user
54
+ ```
55
+
56
+ ### Getting your orders
57
+ If you are an already registered user and simply want to get your orders, you can simply use this method call:
58
+ ```ruby
59
+ Teachable::Order.orders
60
+ ```
61
+
62
+ ### Creating order
63
+ If you are an already registered user and simply want to create order, you can simply use this method call:
64
+ ```ruby
65
+ Teachable::Order.create(total: 3.0, total_quantity: 3, special_instructions: 'some description if needed')
66
+ ```
67
+
68
+ ### Destroy order
69
+ If you are an already registered user and simply want to delete your order, you can simply use this method call:
70
+ ```ruby
71
+ Teachable::Order.destroy(id: 1)
72
+ ```
73
+
74
+ ## Development
75
+
76
+ 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](https://rubygems.org).
77
+
78
+ ## Contributing
79
+
80
+ 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](http://contributor-covenant.org) code of conduct.
81
+
82
+
83
+ ## License
84
+
85
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "teachable"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ require 'teachable/base'
4
+ require 'teachable/user'
5
+ require 'teachable/order'
6
+ require 'teachable/version'
7
+ require 'teachable/configuration'
8
+
9
+ module Teachable
10
+ extend Configuration
11
+ end
@@ -0,0 +1,25 @@
1
+ class Base
2
+ class << self
3
+ private
4
+
5
+ def request_post(path, params = {})
6
+ uri = URI.parse(path.to_s)
7
+ header = { 'Content-Type' => 'application/json' }
8
+
9
+ http = Net::HTTP.new(uri.host, uri.port)
10
+ http.use_ssl = (uri.scheme == 'https')
11
+ request = Net::HTTP::Post.new(uri.request_uri, header)
12
+ request.body = params.to_json
13
+ res = http.request(request)
14
+
15
+ JSON.parse(res.body)
16
+ end
17
+
18
+ def request_get(path, _params = {})
19
+ url = URI.join(path)
20
+ res = Net::HTTP.get_response url
21
+
22
+ JSON.parse(res.body)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ module Teachable
2
+ module Configuration
3
+ DEFAULT_API_TOKEN = nil
4
+ DEFAULT_USER_EMAIL = 'example@example.example'.freeze
5
+ VALID_CONFIG = %i[user_token user_email].freeze
6
+
7
+ attr_accessor *VALID_CONFIG
8
+
9
+ def self.extended(base)
10
+ base.reset
11
+ end
12
+
13
+ def reset
14
+ self.user_token = DEFAULT_API_TOKEN
15
+ self.user_email = DEFAULT_USER_EMAIL
16
+ end
17
+
18
+ def configure
19
+ yield self
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ module Teachable
2
+ class Order < Base
3
+ class << self
4
+ def orders
5
+ request_get("https://fast-bayou-75985.herokuapp.com/api/orders.json?user_email=#{Teachable.user_email}&user_token=#{Teachable.user_token}")
6
+ end
7
+
8
+ def create(params = {})
9
+ request_post("https://fast-bayou-75985.herokuapp.com/api/orders.json?user_email=#{Teachable.user_email}&user_token=#{Teachable.user_token}", order: { total: params[:total], total_quantity: params[:total_quantity], email: Teachable.user_email, special_instructions: params[:special_instructions] })
10
+ end
11
+
12
+ def destroy(params = {})
13
+ request_delete("https://fast-bayou-75985.herokuapp.com/api/orders/#{params[:id]}.json?user_email=#{Teachable.user_email}&user_token=#{Teachable.user_token}")
14
+ end
15
+
16
+ private
17
+
18
+ def request_delete(path, _params = {})
19
+ uri = URI.parse(path.to_s)
20
+ http = Net::HTTP.new(uri.host, uri.port)
21
+ http.use_ssl = (uri.scheme == 'https')
22
+ request = Net::HTTP::Delete.new(uri.request_uri)
23
+ res = http.request(request)
24
+ res.code == '204' ? 'Order was deleted' : "You missed argument 'id' or this order doesn't exist"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ module Teachable
2
+ class User < Base
3
+ def self.registration(params = {})
4
+ request_post('https://fast-bayou-75985.herokuapp.com/users.json', user: { email: params[:email], password: params[:password], password_confirmation: params[:password_confirmation] })
5
+ end
6
+
7
+ def self.authenticate(params = {})
8
+ request_post('https://fast-bayou-75985.herokuapp.com/users/sign_in.json', user: { email: params[:email], password: params[:password] })
9
+ end
10
+
11
+ def self.token(params = {})
12
+ res = authenticate(email: params[:email], password: params[:password])
13
+ res['tokens'] || res
14
+ end
15
+
16
+ def self.get_user
17
+ request_get("https://fast-bayou-75985.herokuapp.com/api/users/current_user/edit.json?user_email=#{Teachable.user_email}&user_token=#{Teachable.user_token}")
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Teachable
2
+ VERSION = '1.1.6'.freeze
3
+ end
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'teachable/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'teachable'
9
+ spec.version = Teachable::VERSION
10
+ spec.authors = ['Gabriel Pedro']
11
+ spec.email = ['pedrogabriel.gp69@gmail.com']
12
+
13
+ spec.summary = 'Gem to wrap teachable.com API'
14
+ spec.description = 'Gem to wrap teachable.com API'
15
+ spec.homepage = 'https://github.com/pedrogabriel69/teachable'
16
+ spec.license = 'MIT'
17
+
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+ else
21
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
22
+ 'public gem pushes.'
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.14'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ spec.add_development_dependency 'rubocop'
36
+ spec.add_development_dependency 'webmock'
37
+ spec.add_development_dependency 'vcr'
38
+ spec.add_development_dependency 'json'
39
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teachable
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Gabriel Pedro
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: vcr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Gem to wrap teachable.com API
112
+ email:
113
+ - pedrogabriel.gp69@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - CODE_OF_CONDUCT.md
122
+ - Gemfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/teachable.rb
129
+ - lib/teachable/base.rb
130
+ - lib/teachable/configuration.rb
131
+ - lib/teachable/order.rb
132
+ - lib/teachable/user.rb
133
+ - lib/teachable/version.rb
134
+ - teachable.gemspec
135
+ homepage: https://github.com/pedrogabriel69/teachable
136
+ licenses:
137
+ - MIT
138
+ metadata:
139
+ allowed_push_host: https://rubygems.org
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.5.1
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Gem to wrap teachable.com API
160
+ test_files: []