lightspeed_ruby 0.1.1 → 0.1.2

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: 349fe8c0c0f68955dfc6e54801916910df7c9098
4
- data.tar.gz: 8d28c61943ea866d23c14bf3da9aa10ba5e8597c
3
+ metadata.gz: 36835acfc096b36433e22cd614acf394f0dff356
4
+ data.tar.gz: f9ae17a208c3d9f872cf166c39761d7827f4f791
5
5
  SHA512:
6
- metadata.gz: d5e4ab3fee51315e0eafb97e8987d7fd47a079022f60976af0858c3a0579efc6abc98d3fb04c836a665b785b277ec626276ab2484864e561d925680cd5cc49fc
7
- data.tar.gz: 56e93f4e5d04aae855e1ebd284196c2a6ae4a5d13481f5487f33e944d5787d115c4eac8ff6fa68f38954fc0fe38abb2d4b8771f5a63acc673a648d1d09208b40
6
+ metadata.gz: baaa633bc435c683cc66b28f55db97d011f30602b6614679775f13a1be5c7a33380d0462fa63cf15ff9b928d9bbb1b9622242a09cd06eace23028c6cc21aa0ad
7
+ data.tar.gz: f0b1dc62ab65677519beda89f8e02b7e8f8758d9e6fba60442506e8ae6473f5a11a5dc5dca49db618440138b2df5424e58f93a405e173f0c6a8a1c64c9211199
@@ -0,0 +1,17 @@
1
+ module Lightspeed
2
+ module API
3
+ class Accounts
4
+ def initialize(client)
5
+ @client = client
6
+ end
7
+
8
+ def all
9
+ client.get("Account.json").body
10
+ end
11
+
12
+ private
13
+
14
+ attr_reader :client
15
+ end
16
+ end
17
+ end
@@ -1,8 +1,9 @@
1
1
  require "lightspeed/api/tokens"
2
+ require "lightspeed/api/accounts"
2
3
 
3
4
  module Lightspeed
4
5
  class Client
5
- API_BASE = "https://api.merchantos.com/API"
6
+ API_BASE = "https://api.merchantos.com/API/"
6
7
 
7
8
  attr_reader :client_id, :client_secret, :access_token, :refresh_token
8
9
 
@@ -13,6 +14,22 @@ module Lightspeed
13
14
  @refresh_token = refresh_token
14
15
  end
15
16
 
17
+ def get(url, params: {})
18
+ conn.get(url, params)
19
+ end
20
+
16
21
  def tokens; API::Tokens.new(self); end
22
+ def accounts; API::Accounts.new(self); end
23
+
24
+ private
25
+
26
+ def conn
27
+ @conn ||= Faraday.new(API_BASE) do |f|
28
+ f.authorization :Bearer, access_token if access_token
29
+ f.request :json
30
+ f.response :json, :content_type => /\bjson$/
31
+ f.adapter Faraday.default_adapter
32
+ end
33
+ end
17
34
  end
18
35
  end
@@ -1,3 +1,3 @@
1
1
  module Lightspeed
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightspeed_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zamith
@@ -83,6 +83,7 @@ files:
83
83
  - bin/console
84
84
  - bin/setup
85
85
  - lib/lightspeed.rb
86
+ - lib/lightspeed/api/accounts.rb
86
87
  - lib/lightspeed/api/tokens.rb
87
88
  - lib/lightspeed/client.rb
88
89
  - lib/lightspeed/errors/missing_refresh_token.rb