frederick_api 0.7 → 0.9
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 -1
- data/lib/frederick_api.rb +2 -0
- data/lib/frederick_api/v2/automation.rb +2 -0
- data/lib/frederick_api/v2/automation_step.rb +14 -0
- data/lib/frederick_api/v2/communication_template.rb +8 -0
- data/lib/frederick_api/v2/helpers/requestor.rb +1 -1
- data/lib/frederick_api/v2/resource.rb +10 -1
- data/lib/frederick_api/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af582661b851880a278f82844f06ec98910f639cf0292ec1249f1ed1127b0a27
|
4
|
+
data.tar.gz: 5740b928ced7a2d9f4964388dbd5e543cbb0827c571f562899ab3a651a030f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd740314950b62480828dc4878a603582edd4bf00c6bddc7e7a6b694707b90da52fd2e31ccdf226b86afeff09aeccd0a12d94b900f322a1e153a3e5a48ce9515
|
7
|
+
data.tar.gz: e535fb7f7655cbf975424497a333292d1dae97c9c8cb3f0621fac118f6e694d360dd355250f1ab91427144038c6a009392c37a0c47a64b4a9536b34a223a6582
|
data/README.md
CHANGED
@@ -88,6 +88,21 @@ FrederickAPI::V2::Location.with_access_token(access_token) do
|
|
88
88
|
end
|
89
89
|
```
|
90
90
|
|
91
|
+
### Using Headers
|
92
|
+
|
93
|
+
`Resource.with_access_token` is extended to take headers in the method `Resource.with_access_token_and_headers`. This is useful when we need to pass the universal customer to services that accept it.
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
access_token = '9jsdo320fjfkfdksls30dfdcd919bcaa1b7804dbbebda0'
|
97
|
+
headers = { 'X-Universal-Customer': '{"source_platform":"mindbody","source_location_id":"1","source_customer_id":"77"}' }
|
98
|
+
|
99
|
+
FrederickAPI::V2::CommunicationTemplate.with_access_token_and_headers(access_token, headers) do
|
100
|
+
template = FrederickAPI::V2::CommunicationTemplate.create(template_attributes)
|
101
|
+
|
102
|
+
template.name
|
103
|
+
# => 'Name from Attrs'
|
104
|
+
end
|
105
|
+
```
|
91
106
|
### Nested Resources
|
92
107
|
|
93
108
|
Nested resources must be accessed using `where` to scope the request:
|
@@ -111,4 +126,4 @@ Polling until the job is complete, fetching and returning the completed resource
|
|
111
126
|
* A FrederickAPI::V2::Errors::BackgroundJobFailure exception is raised if the API returns
|
112
127
|
an error on an asyncronous job.
|
113
128
|
* A BackgroundJob Resource will be returned from the client in the case that a successful
|
114
|
-
job does not return a
|
129
|
+
job does not return a resource.
|
data/lib/frederick_api.rb
CHANGED
@@ -25,6 +25,7 @@ require 'frederick_api/v2/business_category'
|
|
25
25
|
|
26
26
|
# Core resources
|
27
27
|
require 'frederick_api/v2/automation'
|
28
|
+
require 'frederick_api/v2/automation_step'
|
28
29
|
require 'frederick_api/v2/communication_content'
|
29
30
|
require 'frederick_api/v2/contact'
|
30
31
|
require 'frederick_api/v2/contact_property'
|
@@ -34,6 +35,7 @@ require 'frederick_api/v2/interaction'
|
|
34
35
|
require 'frederick_api/v2/role'
|
35
36
|
require 'frederick_api/v2/campaign'
|
36
37
|
require 'frederick_api/v2/email_document'
|
38
|
+
require 'frederick_api/v2/communication_template'
|
37
39
|
|
38
40
|
# Namespace for all Frederick API client methods/classes
|
39
41
|
module FrederickAPI
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FrederickAPI
|
4
|
+
module V2
|
5
|
+
# Resource for automation step
|
6
|
+
class AutomationStep < Resource
|
7
|
+
belongs_to :location
|
8
|
+
has_one :automation
|
9
|
+
has_one :previous_automation_step, class_name: 'FrederickAPI::V2::AutomationStep'
|
10
|
+
|
11
|
+
self.read_only_attributes += %i[location_id]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -56,7 +56,7 @@ module FrederickAPI
|
|
56
56
|
|
57
57
|
path_without_params = "#{uri.scheme}://#{uri.host}#{uri.path}"
|
58
58
|
params = uri.query ? CGI.parse(uri.query).each_with_object({}) { |(k, v), h| h[k] = v[0] } : {}
|
59
|
-
request(:post, path_without_params,
|
59
|
+
request(:post, path_without_params, body: params.to_json, additional_headers: { 'X-Request-Method' => 'GET' })
|
60
60
|
end
|
61
61
|
|
62
62
|
# Retry once on unhandled server errors
|
@@ -36,7 +36,16 @@ module FrederickAPI
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def self.with_access_token(token)
|
39
|
-
|
39
|
+
with_access_token_and_headers(token) do
|
40
|
+
yield
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.with_access_token_and_headers(token, headers = {})
|
45
|
+
with_headers(
|
46
|
+
authorization: "Bearer #{token}",
|
47
|
+
**headers
|
48
|
+
) do
|
40
49
|
yield
|
41
50
|
end
|
42
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frederick_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.9'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frederick Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|
@@ -36,10 +36,12 @@ files:
|
|
36
36
|
- lib/frederick_api.rb
|
37
37
|
- lib/frederick_api/configuration.rb
|
38
38
|
- lib/frederick_api/v2/automation.rb
|
39
|
+
- lib/frederick_api/v2/automation_step.rb
|
39
40
|
- lib/frederick_api/v2/background_job.rb
|
40
41
|
- lib/frederick_api/v2/business_category.rb
|
41
42
|
- lib/frederick_api/v2/campaign.rb
|
42
43
|
- lib/frederick_api/v2/communication_content.rb
|
44
|
+
- lib/frederick_api/v2/communication_template.rb
|
43
45
|
- lib/frederick_api/v2/contact.rb
|
44
46
|
- lib/frederick_api/v2/contact_list.rb
|
45
47
|
- lib/frederick_api/v2/contact_property.rb
|