lightspeed_ruby 0.1.9 → 0.2.0

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: b9cee427c44e3a97df29a3fdaf4209bdfcc00daa
4
- data.tar.gz: 742e83a6c3d50913075bbd939f02f843b5f89c19
3
+ metadata.gz: '0886b5c2d83eed7249e2339f7f561eb97a75ba7c'
4
+ data.tar.gz: 3ce3a727e2eb72b8c12cc183690e51312271d5fe
5
5
  SHA512:
6
- metadata.gz: dee56f0f7a79fa8d002591935debcdf19ed7a1c8dfa56da3aa10eeff7a3e9f6a8c64080172ad1fd82df8bf03a415e06b5acb4fdcbb980892a151241cd7c841c8
7
- data.tar.gz: ecb8fc57d401871aff0bc76180921e9a29c0fe629c0c6b34c9e09487185f8a7f3a74d6009f95054c96eee7d7b5e7231af3829e5d63b3ea6ea06323de4f8bd4a6
6
+ metadata.gz: 23eb41e314c9cfe4d95eac2cdc4f88657c58cf75f250d02f3b175aa3da173acd924dd089ebb40c85f44bff16810fb32b1d4d89a4c55dafaab2e7a6a2fd775c77
7
+ data.tar.gz: bbf32f203f15f472b4142137e63fdc1b1495bb051101003861bdcfc746fc7d072ae567fc19807b1d699cc156f6d33dcf50f9259b318ff969872dc60b093f8bb5
@@ -16,15 +16,13 @@ module Lightspeed
16
16
  end
17
17
 
18
18
  class Client
19
- API_BASE = "https://api.merchantos.com/API/"
20
-
21
19
  attr_reader :access_token, :account_id
22
20
 
23
21
  def self.tokens(client_id:, client_secret:, refresh_token:)
24
22
  API::Tokens.new(client_id, client_secret, refresh_token)
25
23
  end
26
24
 
27
- def initialize(access_token:, account_id:, configuration:)
25
+ def initialize(access_token:, account_id:, configuration: Lightspeed::Configuration.new)
28
26
  @access_token = access_token
29
27
  @account_id = account_id
30
28
  @configuration = configuration
@@ -65,7 +63,7 @@ module Lightspeed
65
63
  attr_reader :configuration
66
64
 
67
65
  def conn
68
- @conn ||= Faraday.new(API_BASE) do |f|
66
+ @conn ||= Faraday.new(Lightspeed.configuration.server) do |f|
69
67
  f.authorization :Bearer, access_token if access_token
70
68
  f.request :json
71
69
  f.response :json, :content_type => /\bjson$/
@@ -1,9 +1,27 @@
1
1
  module Lightspeed
2
2
  class Configuration
3
- attr_accessor :rate_limit
3
+ attr_accessor :rate_limit, :environment
4
4
 
5
5
  def initialize(rate_limit: nil)
6
6
  @rate_limit = rate_limit || false
7
+ @environment = "production"
8
+ end
9
+
10
+ def environment=(env)
11
+ env = env.to_sym
12
+ unless [:development, :production].include?(env)
13
+ raise ArgumentError, "#{env.inspect} is not a valid environment"
14
+ end
15
+ @environment = env
16
+ end
17
+
18
+ def server
19
+ case environment
20
+ when :development
21
+ "http://#{ENV['GATEWAY_SERVER'] || 'localhost:3000'}"
22
+ when :production
23
+ "https://api.merchantos.com/API/"
24
+ end
7
25
  end
8
26
  end
9
27
  end
@@ -1,3 +1,3 @@
1
1
  module Lightspeed
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightspeed_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zamith
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2017-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler