help_scout-sdk 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +14 -4
- data/bin/console +0 -1
- data/lib/help_scout-sdk.rb +0 -1
- data/lib/help_scout/api/access_token.rb +1 -1
- data/lib/help_scout/configuration.rb +0 -7
- data/lib/help_scout/thread.rb +33 -1
- data/lib/help_scout/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d88954135888a77486265cfd3a3755711a419b1883c0e4af31e3c3671d0e67f
|
4
|
+
data.tar.gz: beeb0ecb380ab39348823a61f1d6533617f093e9142c3f78dc0bcb1efff20064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1bd18e9d42821f7df2f1e397fd322af8d765ce522cddffd90b93d24d7390fec98f8a9d381bcf92e64896797c9726d62f8ea687bc6e4044c15592592c1b0b68
|
7
|
+
data.tar.gz: 278dd433006623d04f155b6b30521b6645eb13659c811282efe30cb5d00c4c755877158640a6411cac50dfd968770491b94c78d1588f511ab7cc4402532efd96
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
### master (unreleased)
|
2
|
+
|
3
|
+
### 2.0.0 / 2019-07-19
|
4
|
+
|
5
|
+
Breaking Changes:
|
6
|
+
|
7
|
+
* Removes HelpScout::Configuration#access_token and writer to avoid multiple sources
|
8
|
+
of truth for access token values ([#14](https://github.com/taxjar/help_scout-sdk/pull/14))
|
9
|
+
|
10
|
+
Enhancements:
|
11
|
+
|
12
|
+
* Adds support for `HelpScout::Thread.create`, `HelpScout::Thread.get`, and
|
13
|
+
`HelpScout::Thread#update` (Justin White, [#13](https://github.com/taxjar/help_scout-sdk/pull/13))
|
14
|
+
|
15
|
+
### 1.1.0 / 2019-06-20
|
16
|
+
|
17
|
+
### 1.0.2 / 2019-06-07
|
18
|
+
|
19
|
+
### 1.0.1 / 2019-06-07
|
20
|
+
|
21
|
+
### 1.0.0 / 2019-06-05
|
22
|
+
|
23
|
+
Breaking Changes:
|
24
|
+
|
25
|
+
* Drops support for the Mailbox 1.0 API ([#2](https://github.com/taxjar/help_scout-sdk/pull/2))
|
26
|
+
|
27
|
+
Enhancements:
|
28
|
+
|
29
|
+
* Updated to support the Mailbox 2.0 API ([#2](https://github.com/taxjar/help_scout-sdk/pull/2))
|
data/README.md
CHANGED
@@ -23,8 +23,7 @@ And then execute:
|
|
23
23
|
| :------------------------- | :--: | :--: | :-----: | :----: | :-----: |
|
24
24
|
| Attachment | ❌ | ❌ | ✅ | ❌ | ❌ |
|
25
25
|
| Conversations | ✅ | ✅ | ✅ | ✅ | ❌ |
|
26
|
-
| Conversation::Threads |
|
27
|
-
| Conversation::ThreadSource | ❌ | ❌ | ❌ | ❌ | ❌ |
|
26
|
+
| Conversation::Threads | ✅ | ➖ | ✅ | ✅ | ➖ |
|
28
27
|
| Customers | ✅ | ✅ | ❌ | ❌ | ❌ |
|
29
28
|
| Notes | ❌ | ❌ | ❌ | ❌ | ❌ |
|
30
29
|
| Mailboxes | ✅ | ✅ | ➖ | ➖ | ➖ |
|
@@ -50,8 +49,6 @@ And then execute:
|
|
50
49
|
HelpScout.configure do |config|
|
51
50
|
config.app_id = ENV["HELP_SCOUT_APP_ID"]
|
52
51
|
config.app_secret = ENV["HELP_SCOUT_APP_SECRET"]
|
53
|
-
|
54
|
-
config.access_token = HelpScout::API::AccessToken.create
|
55
52
|
end
|
56
53
|
```
|
57
54
|
|
@@ -86,6 +83,19 @@ mailbox.fields
|
|
86
83
|
mailbox.folders
|
87
84
|
```
|
88
85
|
|
86
|
+
### Threads
|
87
|
+
|
88
|
+
[Documentation Link](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/list/)
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
conversation = HelpScout::Conversation.list.first
|
92
|
+
new_thread = HelpScout::Thread.create(conversation.id, "notes", { text: 'Hello, world!' })
|
93
|
+
threads = HelpScout::Thread.list(conversation.id)
|
94
|
+
latest_thread = threads.first
|
95
|
+
latest_thread.update("replace", "/text", "Updating a threads text.")
|
96
|
+
modified_thread = HelpScout::Thread.get(conversation.id, latest_thread.id)
|
97
|
+
```
|
98
|
+
|
89
99
|
### Users
|
90
100
|
|
91
101
|
[Documentation Link](https://developer.helpscout.com/mailbox-api/endpoints/users/list/)
|
data/bin/console
CHANGED
@@ -11,7 +11,6 @@ HelpScout.configure do |config|
|
|
11
11
|
config.app_id = ENV.fetch('HELP_SCOUT_APP_ID')
|
12
12
|
config.app_secret = ENV.fetch('HELP_SCOUT_APP_SECRET')
|
13
13
|
config.default_mailbox = ENV.fetch('HELP_SCOUT_DEFAULT_MAILBOX')
|
14
|
-
config.access_token = ENV.fetch('HELP_SCOUT_ACCESS_TOKEN', nil)
|
15
14
|
end
|
16
15
|
|
17
16
|
begin
|
data/lib/help_scout-sdk.rb
CHANGED
@@ -16,7 +16,7 @@ module HelpScout
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def refresh!
|
19
|
-
return HelpScout.
|
19
|
+
return HelpScout.access_token unless HelpScout.access_token.nil? || HelpScout.access_token.stale?
|
20
20
|
|
21
21
|
HelpScout.api.access_token = create
|
22
22
|
end
|
@@ -3,17 +3,10 @@
|
|
3
3
|
module HelpScout
|
4
4
|
class Configuration
|
5
5
|
attr_accessor :app_id, :app_secret, :default_mailbox, :token_cache
|
6
|
-
attr_reader :access_token
|
7
6
|
attr_writer :token_cache_key
|
8
7
|
|
9
8
|
DEFAULT_CACHE_KEY = 'help_scout_token_cache'
|
10
9
|
|
11
|
-
def access_token=(token_value)
|
12
|
-
return unless token_value
|
13
|
-
|
14
|
-
@access_token = HelpScout::API::AccessToken.new(access_token: token_value)
|
15
|
-
end
|
16
|
-
|
17
10
|
def token_cache_key
|
18
11
|
return @token_cache_key if defined?(@token_cache_key)
|
19
12
|
|
data/lib/help_scout/thread.rb
CHANGED
@@ -3,12 +3,33 @@
|
|
3
3
|
module HelpScout
|
4
4
|
class Thread < HelpScout::Base
|
5
5
|
class << self
|
6
|
+
def create(conversation_id, thread_type, params)
|
7
|
+
HelpScout.api.post(
|
8
|
+
create_path(conversation_id, thread_type),
|
9
|
+
HelpScout::Util.camelize_keys(params)
|
10
|
+
)
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
6
14
|
def list(conversation_id, page: nil)
|
7
|
-
HelpScout.api.get(
|
15
|
+
HelpScout.api.get(
|
16
|
+
list_path(conversation_id), page: page
|
17
|
+
).embedded_list.map { |details| new details.merge(conversation_id: conversation_id) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(conversation_id, thread_id)
|
21
|
+
threads = list(conversation_id)
|
22
|
+
thread_id = thread_id.to_i
|
23
|
+
|
24
|
+
threads.find { |thread| thread.id == thread_id }
|
8
25
|
end
|
9
26
|
|
10
27
|
private
|
11
28
|
|
29
|
+
def create_path(conversation_id, thread_type)
|
30
|
+
"conversations/#{conversation_id}/#{thread_type}"
|
31
|
+
end
|
32
|
+
|
12
33
|
def list_path(conversation_id)
|
13
34
|
"conversations/#{conversation_id}/threads"
|
14
35
|
end
|
@@ -32,6 +53,7 @@ module HelpScout
|
|
32
53
|
created_at
|
33
54
|
opened_at
|
34
55
|
attachments
|
56
|
+
conversation_id
|
35
57
|
].freeze
|
36
58
|
|
37
59
|
attr_accessor(*BASIC_ATTRIBUTES)
|
@@ -46,5 +68,15 @@ module HelpScout
|
|
46
68
|
|
47
69
|
@hrefs = HelpScout::Util.map_links(params.fetch(:_links, []))
|
48
70
|
end
|
71
|
+
|
72
|
+
def conversation
|
73
|
+
@_conversation ||= HelpScout::Conversation.get(conversation_id)
|
74
|
+
end
|
75
|
+
|
76
|
+
def update(operation, path, value = nil)
|
77
|
+
update_path = "conversations/#{conversation_id}/threads/#{id}"
|
78
|
+
HelpScout.api.patch(update_path, op: operation, path: path, value: value)
|
79
|
+
true
|
80
|
+
end
|
49
81
|
end
|
50
82
|
end
|
data/lib/help_scout/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: help_scout-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TaxJar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- ".rspec"
|
224
224
|
- ".rubocop.yml"
|
225
225
|
- ".travis.yml"
|
226
|
+
- CHANGELOG.md
|
226
227
|
- CODE_OF_CONDUCT.md
|
227
228
|
- Gemfile
|
228
229
|
- LICENSE.txt
|