helpscout_api 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/lib/helpscout_api/client.rb +14 -9
- data/lib/helpscout_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecbab3106bcb8e53f6fdd6777b5ec7059dda3018e8e96d461ec48d2e5c51fa9a
|
4
|
+
data.tar.gz: 9b88a9265cca79b220576d124c137ec604fdbb86e0bff542c43841f58a3254bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
25
|
-
|
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/
|
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/
|
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).
|
data/lib/helpscout_api/client.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
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
|
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']
|
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.
|
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-
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|