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 +4 -4
- data/lib/lightspeed/client.rb +2 -4
- data/lib/lightspeed/configuration.rb +19 -1
- data/lib/lightspeed/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0886b5c2d83eed7249e2339f7f561eb97a75ba7c'
|
4
|
+
data.tar.gz: 3ce3a727e2eb72b8c12cc183690e51312271d5fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23eb41e314c9cfe4d95eac2cdc4f88657c58cf75f250d02f3b175aa3da173acd924dd089ebb40c85f44bff16810fb32b1d4d89a4c55dafaab2e7a6a2fd775c77
|
7
|
+
data.tar.gz: bbf32f203f15f472b4142137e63fdc1b1495bb051101003861bdcfc746fc7d072ae567fc19807b1d699cc156f6d33dcf50f9259b318ff969872dc60b093f8bb5
|
data/lib/lightspeed/client.rb
CHANGED
@@ -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(
|
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
|
data/lib/lightspeed/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|