helpscout_api 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 7f988be1e5e6b85055a1981734b26c4eacd1c53ff39e4193c5701b9a3310c69b
4
- data.tar.gz: ed9c81ef958817f9f7c37e7431cec6499511a7bca1f9b035415b7dbca548bf34
3
+ metadata.gz: ecbab3106bcb8e53f6fdd6777b5ec7059dda3018e8e96d461ec48d2e5c51fa9a
4
+ data.tar.gz: 9b88a9265cca79b220576d124c137ec604fdbb86e0bff542c43841f58a3254bc
5
5
  SHA512:
6
- metadata.gz: '08ea175cbdbbdebb33db12a305e2c0f1b41590f729f8b2cbb9f230c1aae54438d3c7c0b352d40ba5fbe46680a3af97522c339d173f2166a487b17f196e628eee'
7
- data.tar.gz: 032d2a72c7504771135168513fef4964b11791b0ab427f97c24e31e84822c6b04ec8f3ecc405d7358d119691214200e1173bb6b8aa7a9e5a4482ff42b7ff6a48
6
+ metadata.gz: b8cbf0e748de7fb6dfb3d203a9c727ff837cd4a9a457285c358a7fcafb89188520c81d450e3c6e33e607deccbc5facddbefa7081b4b22e6a50b5668f27ebc30b
7
+ data.tar.gz: 0d2c2abd73afe39a7e60182eb6a47870be623763179ab3f354771c346b4966c4c4cdd17b3f268ff142e0750c616feed6fc5e5494e6fab743741678f2a625410a
data/README.md CHANGED
@@ -21,8 +21,11 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  ```ruby
24
- # Authenticate your client
25
- client = HelpscoutApi::Client.new(api_token: YOUR_API_TOKEN)
24
+ # Set your api_token
25
+ HelpscoutApi::Client.api_token = YOUR_API_TOKEN
26
+
27
+ # Create your client
28
+ client = HelpscoutApi::Client.new()
26
29
 
27
30
  # List resources
28
31
  client.<resource>.list(<params>)
@@ -53,7 +56,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
53
56
 
54
57
  ## Contributing
55
58
 
56
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/helpscout_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
59
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bitbond/helpscout_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
57
60
 
58
61
  ## License
59
62
 
@@ -61,4 +64,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
61
64
 
62
65
  ## Code of Conduct
63
66
 
64
- Everyone interacting in the HelpscoutApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/helpscout_api/blob/master/CODE_OF_CONDUCT.md).
67
+ Everyone interacting in the HelpscoutApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bitbond/helpscout_api/blob/master/CODE_OF_CONDUCT.md).
@@ -2,20 +2,25 @@ require 'httparty'
2
2
 
3
3
  module HelpscoutApi
4
4
 
5
- HEADERS = { "Content-Type" => "application/json" }
6
- API_VERSION = "v1"
7
-
8
5
  class Client
9
-
10
6
  include HTTParty
11
7
  format :json
12
- attr_accessor :api_token, :auth_params
8
+
9
+ HEADERS = { "Content-Type" => "application/json" }
10
+ API_VERSION = "v1"
11
+
13
12
  headers HEADERS
14
13
  base_uri "https://api.helpscout.net/#{API_VERSION}/"
15
14
 
16
- def initialize(api_token:)
17
- @api_token = api_token
18
- @auth_params = { username: api_token, password: "X" }
15
+ attr_accessor :auth_params
16
+
17
+ class << self
18
+ attr_accessor :api_token
19
+ @api_token = nil
20
+ end
21
+
22
+ def initialize
23
+ @auth_params = { username: self.class.api_token, password: "X" }
19
24
  end
20
25
 
21
26
  def list(**params)
@@ -58,7 +63,7 @@ module HelpscoutApi
58
63
  case response.code
59
64
  when 200..299
60
65
  response.parsed_response
61
- when 403..404
66
+ when 400..404
62
67
  raise HTTParty::Error, response.parsed_response['error']
63
68
  when 500..600
64
69
  raise HTTParty::Error, response.parsed_response['error']
@@ -1,3 +1,3 @@
1
1
  module HelpscoutApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helpscout_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - garethfuller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-13 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler