chord 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d80163ac430fb1f71487c3a0656a89b110ebb4642169428675944ae5f97d241
4
- data.tar.gz: 38ee178bc55275a7ea3e3b56538ec281daee425fa2885ecf5cb7580a77bbd356
3
+ metadata.gz: d87fc026e550a99125b7aac97b1069d943ccc8b6c23f4bface9ae5136d2fd48d
4
+ data.tar.gz: ca017e9919b6323d25f0dbac900598be630c843120bef07f1db29787e94b675d
5
5
  SHA512:
6
- metadata.gz: 2422e06e382c5a9f8e752d79e45348582024318a7ec4858044cd0852174a66eb441772133d36f47f95033885c3a083e3de1d8ff041075c78498e8320a42b625e
7
- data.tar.gz: 4acad1139ba34288cbb43c781e2bfe0d3c98b0ee3db9826cd025bbf5b269a11e776f22ce1e53c19bdb64f9910a4929d5dba351b22110084cbeb8dd466c7963d1
6
+ metadata.gz: e027f417299124bbcf66d573ddd4ddb36f9a3c3d193385df49b2499ed9658543b58375064ba4cd583777a66be63ef685c036ba3616f7813bd34ebd857753d34a
7
+ data.tar.gz: fc10bf3c2ff5b9fd59048024ff07f3288b9593aea3da6a90fc35b11697d992bdcc48b00d873bbc07685b63440e9a228dc27330409568d98073f1e9adc51c0416
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  Major changes for each release. Please see the Git log for complete list of changes.
4
4
 
5
+ ## 0.0.4
6
+
7
+ * Load attribute if missing.
8
+
9
+ ## 0.0.3
10
+
11
+ * Refactor configuration.
12
+
5
13
  ## 0.0.2
6
14
 
7
15
  * Don't memoize filtered queries.
data/README.md CHANGED
@@ -2,16 +2,10 @@
2
2
 
3
3
  These classes provide simple read and write access to the Chord OMS API. Get started like this:
4
4
 
5
- CHORD_API_CONFIG = {
6
- staging: {
7
- base_url: 'https://<customer>.staging.assembly-api.com/api/',
8
- api_key: '<key>'
9
- },
10
- production: {
11
- base_url: 'https://<customer>.assembly-api.com/api/',
12
- api_key: '<key>'
13
- }
14
- }
5
+ Chord.config(
6
+ base_url: 'https://<customer>.staging.assembly-api.com/api/',
7
+ api_key: '<key>'
8
+ )
15
9
 
16
10
  u = Chord::User.find(1) # fetch user
17
11
  u.attributes # see attributes hash
data/bin/console CHANGED
@@ -3,10 +3,7 @@
3
3
  require 'bundler/setup'
4
4
  require 'chord'
5
5
 
6
- if File.exist?('config.yml')
7
- require 'yaml'
8
- CHORD_API_CONFIG = YAML.load(File.read('config.yml'), symbolize_names: true)
9
- end
6
+ Chord.config_from_file('config.yml')
10
7
 
11
8
  require 'irb'
12
9
  IRB.start
data/lib/chord/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Chord
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/chord.rb CHANGED
@@ -3,8 +3,24 @@ require 'httparty'
3
3
  module Chord
4
4
 
5
5
  class << self
6
- attr_writer :env
7
- def env; @env || :staging; end # :staging by default
6
+ attr_accessor :base_url
7
+ attr_accessor :api_key
8
+
9
+ def config(options)
10
+ self.base_url = options[:base_url]
11
+ self.api_key = options[:api_key]
12
+ end
13
+
14
+ def config_from_file(filepath)
15
+ if File.exist?(filepath)
16
+ require 'yaml'
17
+ config = YAML.load(File.read(filepath), symbolize_names: true)
18
+ Chord.config(
19
+ base_url: config[:base_url],
20
+ api_key: config[:api_key]
21
+ )
22
+ end
23
+ end
8
24
  end
9
25
 
10
26
  class Base
@@ -35,12 +51,12 @@ module Chord
35
51
  end
36
52
 
37
53
  def base_url
38
- CHORD_API_CONFIG[Chord.env][:base_url]
54
+ Chord.base_url
39
55
  end
40
56
 
41
57
  def http_options
42
58
  {headers: {
43
- 'Authorization' => "Bearer #{CHORD_API_CONFIG[Chord.env][:api_key]}",
59
+ 'Authorization' => "Bearer #{Chord.api_key}",
44
60
  'Content-Type' => 'application/json'
45
61
  }}
46
62
  end
@@ -176,6 +192,17 @@ module Chord
176
192
  http_options.merge(body: attributes.to_json)
177
193
  ).parsed_response
178
194
  end
195
+
196
+ def subscription_installment?
197
+ channel == 'subscriptions'
198
+ end
199
+
200
+ def subscription_start?
201
+ unless attributes.include?('subscription_in_cart')
202
+ attributes['subscription_in_cart'] = Chord::Order.find(number).subscription_in_cart
203
+ end
204
+ subscription_in_cart
205
+ end
179
206
  end
180
207
 
181
208
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner