lucid_intercom 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -7
- data/lib/lucid_intercom/company_custom_attributes.rb +1 -1
- data/lib/lucid_intercom/config.rb +28 -31
- data/lib/lucid_intercom/event.rb +1 -1
- data/lib/lucid_intercom/post_request.rb +1 -1
- data/lib/lucid_intercom/render_snippet.rb +1 -1
- data/lib/lucid_intercom/send_email.rb +1 -1
- data/lib/lucid_intercom/send_message.rb +1 -1
- data/lib/lucid_intercom/types.rb +7 -0
- data/lib/lucid_intercom/user_attributes.rb +1 -1
- data/lib/lucid_intercom/version.rb +1 -1
- data/lib/lucid_intercom.rb +4 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c68b630c07ce2c240795b154f8d5c874db29c516e357582b4f1dcfe8e4504f50
|
4
|
+
data.tar.gz: f2f796e2d8e4cea69af445d8a17befa36dec12c7abceed9eaa43172c970b8da8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a41991df15b5cf39e7e97d9e00fce2380765f96dabe2907fa684b539d3e504de095eb09b0f6c4d7e9e0194245cc7d2127e7816b471de1cae610c363a07a750d
|
7
|
+
data.tar.gz: a57a7947ffde3d25d6aa844d8ba1ea16e4e3cacc3ef307751a397d2d0f4df2dde82a2f0538213694446e3127359a5f08c3d2546eb633bf9c509f2b91ee61c98c
|
data/README.md
CHANGED
@@ -14,15 +14,24 @@ Usage
|
|
14
14
|
|
15
15
|
### Configure the default API credentials
|
16
16
|
|
17
|
-
LucidIntercom.
|
18
|
-
'...',
|
19
|
-
|
20
|
-
'...',
|
21
|
-
'...',
|
22
|
-
|
17
|
+
LucidIntercom.configure(
|
18
|
+
access_token: '...',
|
19
|
+
admin_id: 123456,
|
20
|
+
app_id: '...',
|
21
|
+
app_prefix: '...',
|
22
|
+
secret: '...',
|
23
23
|
)
|
24
24
|
|
25
|
-
Here, ‘app_prefix’ is the snakecased app name, e.g. ‘smart_order_tags
|
25
|
+
Here, ‘app_prefix’ is the snakecased app name, e.g. ‘smart_order_tags’.
|
26
|
+
|
27
|
+
Alternatively load the configuration from a Ruby file. The Ruby
|
28
|
+
file is evaluated and should return a hash.
|
29
|
+
|
30
|
+
LucidIntercom.configure_from_file('config/intercom.rb') # the default path
|
31
|
+
|
32
|
+
When loading from a file, any environment variables matching the
|
33
|
+
upcased key with the prefix ‘INTERCOM_’ will override values in the
|
34
|
+
file. For example ‘INTERCOM_APP_ID=...’.
|
26
35
|
|
27
36
|
|
28
37
|
### Render the browser snippet
|
@@ -1,51 +1,48 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'forwardable'
|
4
|
-
|
5
3
|
require 'lucid_intercom'
|
4
|
+
require 'lucid_utils'
|
6
5
|
|
7
6
|
module LucidIntercom
|
8
7
|
NotConfiguredError = Class.new(Error)
|
9
8
|
|
10
9
|
class << self
|
11
|
-
|
10
|
+
#
|
11
|
+
# @param options [Hash]
|
12
|
+
#
|
13
|
+
# @return [Config]
|
14
|
+
#
|
15
|
+
def configure(options = {})
|
16
|
+
@config = Config.new(
|
17
|
+
**@config.to_h.compact,
|
18
|
+
**options,
|
19
|
+
)
|
20
|
+
end
|
12
21
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
)
|
22
|
+
#
|
23
|
+
# @param path [String]
|
24
|
+
#
|
25
|
+
# @return [Config]
|
26
|
+
#
|
27
|
+
def configure_from_file(path = 'config/intercom.rb')
|
28
|
+
options = LucidUtils::ConfigFromFile.new.(path, env_prefix: 'intercom')
|
21
29
|
|
22
|
-
|
23
|
-
|
30
|
+
configure(options)
|
31
|
+
end
|
24
32
|
|
25
33
|
#
|
26
34
|
# @return [Config]
|
27
35
|
#
|
28
|
-
# @raise [NotConfiguredError] if config is unset
|
29
|
-
#
|
30
36
|
def config
|
31
|
-
|
32
|
-
|
33
|
-
@config
|
37
|
+
@config ||= configure
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
37
|
-
class Config
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
param :secret
|
44
|
-
# @return [String]
|
45
|
-
param :app_id
|
46
|
-
# @return [String] the snakecased app name, e.g. 'smart_order_tags'
|
47
|
-
param :app_prefix
|
48
|
-
# @return [Integer]
|
49
|
-
param :admin_id
|
41
|
+
class Config < Dry::Struct
|
42
|
+
attribute :access_token, Types::String
|
43
|
+
attribute :admin_id, Types::Integer
|
44
|
+
attribute :app_id, Types::String
|
45
|
+
attribute :app_prefix, Types::String # the snakecased app name, e.g. 'smart_order_tags'
|
46
|
+
attribute :secret, Types::String
|
50
47
|
end
|
51
48
|
end
|
data/lib/lucid_intercom/event.rb
CHANGED
@@ -19,7 +19,7 @@ module LucidIntercom
|
|
19
19
|
#
|
20
20
|
def call(path, data)
|
21
21
|
res = @http.headers(
|
22
|
-
'Authorization' => "Bearer #{LucidIntercom.access_token}",
|
22
|
+
'Authorization' => "Bearer #{LucidIntercom.config.access_token}",
|
23
23
|
'Accept' => 'application/json',
|
24
24
|
'Content-Type' => 'application/json'
|
25
25
|
).post("https://api.intercom.io/#{path}", json: data)
|
data/lib/lucid_intercom.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'dry/initializer'
|
4
|
+
require 'dry/struct'
|
4
5
|
|
5
6
|
module LucidIntercom
|
6
7
|
autoload :Attributes, 'lucid_intercom/attributes.rb'
|
@@ -19,7 +20,10 @@ module LucidIntercom
|
|
19
20
|
autoload :Response, 'lucid_intercom/response.rb'
|
20
21
|
autoload :SendEmail, 'lucid_intercom/send_email.rb'
|
21
22
|
autoload :SendMessage, 'lucid_intercom/send_message.rb'
|
23
|
+
autoload :Types, 'lucid_intercom/types.rb'
|
22
24
|
autoload :UpdateUser, 'lucid_intercom/update_user.rb'
|
23
25
|
autoload :UserAttributes, 'lucid_intercom/user_attributes.rb'
|
24
26
|
autoload :VERSION, 'lucid_intercom/version.rb'
|
25
27
|
end
|
28
|
+
|
29
|
+
require 'lucid_intercom/config'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucid_intercom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelsey Judson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dry-struct
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: http
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '4.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: lucid_utils
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.0'
|
97
125
|
description:
|
98
126
|
email: kelsey@lucid.nz
|
99
127
|
executables: []
|
@@ -119,6 +147,7 @@ files:
|
|
119
147
|
- lib/lucid_intercom/send_email.rb
|
120
148
|
- lib/lucid_intercom/send_message.rb
|
121
149
|
- lib/lucid_intercom/snippet.html
|
150
|
+
- lib/lucid_intercom/types.rb
|
122
151
|
- lib/lucid_intercom/update_user.rb
|
123
152
|
- lib/lucid_intercom/user_attributes.rb
|
124
153
|
- lib/lucid_intercom/version.rb
|