teachable-jg 0.0.5 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82dcfd7be7c363d988e8c6e0a04700b1931d524d
4
- data.tar.gz: a266cc103e6a9cd031c703f4aaf7db50cf75fe93
3
+ metadata.gz: 9723db89952fca603ae20865254d748b1ea15ce6
4
+ data.tar.gz: 4e677735ec3ecd70ca734bb2625e9eab001681ce
5
5
  SHA512:
6
- metadata.gz: c4c9b3644c1bdf706772fd4d63b52fdc599b3f749738a0bec53aed1daa5ccab34c1289ac59aceab676ec812f789eb0900828d96b0d9bae29c18a6e908eb2fabd
7
- data.tar.gz: 5793a206433d2b407ac7425c14407a900427b2eeb34972be1a111f18fef06966c4c2e52b83e5bd8c56ab5864f9528af97d73472eda1d9434a586266aaa79abea
6
+ metadata.gz: dae902b0c020301bfa3fc7aadd7c9fbaf522ce72997a20763a6596a3d8e5c64a063d07ee78639dc1bf5570d074dd8a654f9993ecbfbbbe37d4d54da331ffccf0
7
+ data.tar.gz: 45a96a2b32e19074cdc36141028a9bc7f77e77ad0f262abc14cd7df123a83b856b73fee7d884e20d07371c262dab86eab88976229a3c6f0911b78aa0cdf964b5
@@ -107,6 +107,49 @@ module Teachable
107
107
  end
108
108
  end
109
109
 
110
+ def post_to_orders(path, options)
111
+ query = {order: {
112
+ "total" => options[:total],
113
+ "total_quantity" => options[:total_quantity],
114
+ "email" => options[:email],
115
+ "special_instructions" => options[:special_instructions]
116
+ }}
117
+
118
+ path_with_params = path + "?user_email=#{options[:user_email]}&user_token=#{options[:user_token]}"
119
+
120
+ resp = HTTParty.post(
121
+ path_with_params,
122
+ query: query,
123
+ headers: headers
124
+ )
125
+
126
+ if resp.code == 200
127
+ body = process_body(resp.body)
128
+ self.delivered = true if body["success"]
129
+ return body
130
+ else
131
+ return resp.code
132
+ end
133
+ end
134
+
135
+ def create_order(options)
136
+ if authorized
137
+ path = options[:path] || Teachable::Jg::Configuration::ORDERS_ENDPOINT
138
+ if options[:total] && !options[:total].nil? &&
139
+ options[:total_quantity] && !options[:total_quantity].nil? &&
140
+ options[:email] && !options[:email].nil?
141
+ resp = post_to_orders(path, options)
142
+ else
143
+ self.delivered = false
144
+ {"success"=>false, "create_order"=>"missing or invalid params"}
145
+ end
146
+ else
147
+ self.delivered = false
148
+ {"success"=>false, "login"=>"failed to authorize"}
149
+ end
150
+
151
+ end
152
+
110
153
  end # Client
111
154
  end
112
155
  end
@@ -7,6 +7,9 @@ module Teachable
7
7
  VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
8
8
 
9
9
  DEFAULT_ENDPOINT = 'http://secure.localhost.com:3000/users'
10
+ CURRENT_USER_ENDPOINT = "http://secure.localhost.com:3000/api/users/current_user/edit"
11
+ ORDERS_ENDPOINT = "http://secure.localhost.com:3000/api/orders"
12
+
10
13
  DEFAULT_METHOD = :post
11
14
  DEFAULT_USER_AGENT = "Teachable API Ruby Gem #{Teachable::Jg::VERSION}".freeze
12
15
  DEFAULT_FORMAT = :json
@@ -16,7 +19,6 @@ module Teachable
16
19
  "Accept" => "application/json" }
17
20
  DEFAULT_STATUS_MESSAGE = ""
18
21
 
19
- CURRENT_USER_ENDPOINT = "http://secure.localhost.com:3000/api/users/current_user/edit"
20
22
 
21
23
  # Build accessor methods for every config options so we can do this, for example:
22
24
  # Teachable::Jg.format = :xml
@@ -1,5 +1,5 @@
1
1
  module Teachable
2
2
  module Jg
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teachable-jg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua