yext-api 0.1.5 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b00aa1601c943ccd86176b00dbd9d0dc2cfe62ba
4
- data.tar.gz: 3dc9545705404a5c812be0d70e77d57f6f61e8e2
2
+ SHA256:
3
+ metadata.gz: 79f491a325f8a7fe9babafb710683b254203480cf0079778fb4bc95f27f782f1
4
+ data.tar.gz: 2895fbcf074a7426a08fd774493fe99c629e66752b6a1ae24cccc471761d6007
5
5
  SHA512:
6
- metadata.gz: 55c0f57e48913eddf4ae516022b76ecc9a44ff5b257280b1aa56d4c28e66df12f8023128ea8d2de1443a07e6713b5a43a0ab16e6ab0bbc7157ee6ad6cf9331bf
7
- data.tar.gz: 01d6deaaaaedac4668c22ad2808c1d39fa7ad5e6f6bc7478c144b34e0726811229f0b84b8cbc83c4628eafbdb6f1e2795882c3c9e2b7f8bcf9a2717722ac7411
6
+ metadata.gz: 865eca22ad249420077c5e765a8aae0547b8940db876c78b81a20b37c006da8564332bf1906143ac50d4d913eed4845308165f407bd1e4121122b2ef9bdb9871
7
+ data.tar.gz: 9eea3c5b24427bca7eebb971e4f3acb117db6a7d2b81f16a9e2dc7b0e49563aea99f13e76d065b34253b401865bd687481169e4e296fe338220dedaf6b5cad7c
@@ -0,0 +1,53 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.6.3-node-browsers
11
+
12
+ # Specify service dependencies here if necessary
13
+ # CircleCI maintains a library of pre-built images
14
+ # documented at https://circleci.com/docs/2.0/circleci-images/
15
+ # - image: circleci/postgres:9.4
16
+
17
+ working_directory: ~/repo
18
+
19
+ steps:
20
+ - checkout
21
+
22
+ # Download and cache dependencies
23
+ - restore_cache:
24
+ keys:
25
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
26
+ # fallback to using the latest cache if no exact match is found
27
+ - v1-dependencies-
28
+
29
+ - run:
30
+ name: install dependencies
31
+ command: |
32
+ gem install bundler
33
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
34
+ - save_cache:
35
+ paths:
36
+ - ./venv
37
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
38
+
39
+ # run tests!
40
+ - run:
41
+ name: run tests
42
+ command: |
43
+ mkdir /tmp/test-results
44
+ bundle exec rspec --format progress \
45
+ --format RspecJunitFormatter \
46
+ --out /tmp/test-results/rspec.xml \
47
+ --format progress
48
+ # collect reports
49
+ - store_test_results:
50
+ path: /tmp/test-results
51
+ - store_artifacts:
52
+ path: /tmp/test-results
53
+ destination: test-results
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.6.3
data/Gemfile CHANGED
@@ -7,6 +7,4 @@ git_source(:github) { |_repo_name| "https://github.com/CardTapp/yext-api" }
7
7
  # Specify your gem's dependencies in yext-api.gemspec
8
8
  gemspec
9
9
 
10
- gem "codecov"
11
10
  gem "gem-release"
12
- gem "simplecov"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yext-api (0.1.5)
4
+ yext-api (0.1.11)
5
5
  memoist (~> 0)
6
6
  rails (> 4)
7
7
  spyke (~> 5)
@@ -10,46 +10,50 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actioncable (5.1.4)
14
- actionpack (= 5.1.4)
13
+ actioncable (5.2.0)
14
+ actionpack (= 5.2.0)
15
15
  nio4r (~> 2.0)
16
- websocket-driver (~> 0.6.1)
17
- actionmailer (5.1.4)
18
- actionpack (= 5.1.4)
19
- actionview (= 5.1.4)
20
- activejob (= 5.1.4)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailer (5.2.0)
18
+ actionpack (= 5.2.0)
19
+ actionview (= 5.2.0)
20
+ activejob (= 5.2.0)
21
21
  mail (~> 2.5, >= 2.5.4)
22
22
  rails-dom-testing (~> 2.0)
23
- actionpack (5.1.4)
24
- actionview (= 5.1.4)
25
- activesupport (= 5.1.4)
23
+ actionpack (5.2.0)
24
+ actionview (= 5.2.0)
25
+ activesupport (= 5.2.0)
26
26
  rack (~> 2.0)
27
27
  rack-test (>= 0.6.3)
28
28
  rails-dom-testing (~> 2.0)
29
29
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
30
- actionview (5.1.4)
31
- activesupport (= 5.1.4)
30
+ actionview (5.2.0)
31
+ activesupport (= 5.2.0)
32
32
  builder (~> 3.1)
33
33
  erubi (~> 1.4)
34
34
  rails-dom-testing (~> 2.0)
35
35
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
36
- activejob (5.1.4)
37
- activesupport (= 5.1.4)
36
+ activejob (5.2.0)
37
+ activesupport (= 5.2.0)
38
38
  globalid (>= 0.3.6)
39
- activemodel (5.1.4)
40
- activesupport (= 5.1.4)
41
- activerecord (5.1.4)
42
- activemodel (= 5.1.4)
43
- activesupport (= 5.1.4)
44
- arel (~> 8.0)
45
- activesupport (5.1.4)
39
+ activemodel (5.2.0)
40
+ activesupport (= 5.2.0)
41
+ activerecord (5.2.0)
42
+ activemodel (= 5.2.0)
43
+ activesupport (= 5.2.0)
44
+ arel (>= 9.0)
45
+ activestorage (5.2.0)
46
+ actionpack (= 5.2.0)
47
+ activerecord (= 5.2.0)
48
+ marcel (~> 0.3.1)
49
+ activesupport (5.2.0)
46
50
  concurrent-ruby (~> 1.0, >= 1.0.2)
47
- i18n (~> 0.7)
51
+ i18n (>= 0.7, < 2)
48
52
  minitest (~> 5.1)
49
53
  tzinfo (~> 1.1)
50
54
  addressable (2.5.2)
51
55
  public_suffix (>= 2.0.2, < 4.0)
52
- arel (8.0.0)
56
+ arel (9.0.0)
53
57
  builder (3.2.3)
54
58
  codecov (0.1.10)
55
59
  json
@@ -60,64 +64,70 @@ GEM
60
64
  activesupport
61
65
  crack (0.4.3)
62
66
  safe_yaml (~> 1.0.0)
63
- crass (1.0.3)
67
+ crass (1.0.4)
64
68
  diff-lcs (1.3)
65
69
  docile (1.1.5)
66
- erubi (1.7.0)
67
- faraday (0.14.0)
70
+ erubi (1.7.1)
71
+ faraday (1.0.1)
68
72
  multipart-post (>= 1.2, < 3)
69
- faraday_middleware (0.12.2)
70
- faraday (>= 0.7.4, < 1.0)
73
+ faraday_middleware (1.0.0)
74
+ faraday (~> 1.0)
71
75
  gem-release (1.0.0)
72
- globalid (0.4.1)
76
+ globalid (0.4.2)
73
77
  activesupport (>= 4.2.0)
74
78
  hashdiff (0.3.7)
75
79
  hashie (3.5.7)
76
- i18n (0.9.1)
80
+ i18n (1.0.1)
77
81
  concurrent-ruby (~> 1.0)
78
82
  json (2.1.0)
79
- loofah (2.1.1)
80
83
  crass (~> 1.0.2)
81
84
  nokogiri (>= 1.5.9)
82
- mail (2.7.0)
85
+ loofah (2.2.2)
86
+ crass (~> 1.0.2)
87
+ nokogiri (>= 1.5.9)
88
+ mail (2.7.1)
83
89
  mini_mime (>= 0.1.1)
84
- memoist (0.16.0)
90
+ marcel (0.3.3)
91
+ mimemagic (~> 0.3.2)
92
+ memoist (0.16.2)
85
93
  method_source (0.9.0)
86
- mini_mime (1.0.0)
87
- mini_portile2 (2.3.0)
88
- minitest (5.11.1)
89
- multipart-post (2.0.0)
90
- nio4r (2.2.0)
91
- nokogiri (1.8.1)
92
- mini_portile2 (~> 2.3.0)
94
+ mimemagic (0.3.4)
95
+ mini_mime (1.0.2)
96
+ mini_portile2 (2.4.0)
97
+ minitest (5.11.3)
98
+ multipart-post (2.1.1)
99
+ nio4r (2.5.2)
100
+ nokogiri (1.10.8)
101
+ mini_portile2 (~> 2.4.0)
93
102
  public_suffix (3.0.1)
94
- rack (2.0.3)
95
- rack-test (0.8.2)
103
+ rack (2.0.8)
104
+ rack-test (1.0.0)
96
105
  rack (>= 1.0, < 3)
97
- rails (5.1.4)
98
- actioncable (= 5.1.4)
99
- actionmailer (= 5.1.4)
100
- actionpack (= 5.1.4)
101
- actionview (= 5.1.4)
102
- activejob (= 5.1.4)
103
- activemodel (= 5.1.4)
104
- activerecord (= 5.1.4)
105
- activesupport (= 5.1.4)
106
+ rails (5.2.0)
107
+ actioncable (= 5.2.0)
108
+ actionmailer (= 5.2.0)
109
+ actionpack (= 5.2.0)
110
+ actionview (= 5.2.0)
111
+ activejob (= 5.2.0)
112
+ activemodel (= 5.2.0)
113
+ activerecord (= 5.2.0)
114
+ activestorage (= 5.2.0)
115
+ activesupport (= 5.2.0)
106
116
  bundler (>= 1.3.0)
107
- railties (= 5.1.4)
117
+ railties (= 5.2.0)
108
118
  sprockets-rails (>= 2.0.0)
109
119
  rails-dom-testing (2.0.3)
110
120
  activesupport (>= 4.2.0)
111
121
  nokogiri (>= 1.6)
112
- rails-html-sanitizer (1.0.3)
113
- loofah (~> 2.0)
114
- railties (5.1.4)
115
- actionpack (= 5.1.4)
116
- activesupport (= 5.1.4)
122
+ rails-html-sanitizer (1.0.4)
123
+ loofah (~> 2.2, >= 2.2.2)
124
+ railties (5.2.0)
125
+ actionpack (= 5.2.0)
126
+ activesupport (= 5.2.0)
117
127
  method_source
118
128
  rake (>= 0.8.7)
119
129
  thor (>= 0.18.1, < 2.0)
120
- rake (10.4.2)
130
+ rake (13.0.1)
121
131
  rspec (3.6.0)
122
132
  rspec-core (~> 3.6.0)
123
133
  rspec-expectations (~> 3.6.0)
@@ -139,6 +149,8 @@ GEM
139
149
  rspec-mocks (~> 3.6.0)
140
150
  rspec-support (~> 3.6.0)
141
151
  rspec-support (3.6.0)
152
+ rspec_junit_formatter (0.4.1)
153
+ rspec-core (>= 2, < 4, != 2.12.0)
142
154
  safe_yaml (1.0.4)
143
155
  simplecov (0.15.1)
144
156
  docile (~> 1.1.0)
@@ -147,22 +159,22 @@ GEM
147
159
  simplecov-html (0.10.2)
148
160
  simplecov-rcov (0.2.3)
149
161
  simplecov (>= 0.4.1)
150
- sprockets (3.7.1)
162
+ sprockets (4.0.0)
151
163
  concurrent-ruby (~> 1.0)
152
164
  rack (> 1, < 3)
153
165
  sprockets-rails (3.2.1)
154
166
  actionpack (>= 4.0)
155
167
  activesupport (>= 4.0)
156
168
  sprockets (>= 3.0.0)
157
- spyke (5.3.0)
158
- activemodel (>= 4.0.0, < 6.0)
159
- activesupport (>= 4.0.0, < 6.0)
169
+ spyke (5.3.4)
170
+ activemodel (>= 4.0.0)
171
+ activesupport (>= 4.0.0)
160
172
  addressable (>= 2.5.2)
161
173
  faraday (>= 0.9.0, < 2.0)
162
174
  faraday_middleware (>= 0.9.1, < 2.0)
163
175
  thor (0.20.0)
164
176
  thread_safe (0.3.6)
165
- tzinfo (1.2.4)
177
+ tzinfo (1.2.5)
166
178
  thread_safe (~> 0.1)
167
179
  url (0.3.2)
168
180
  valid (1.2.0)
@@ -171,9 +183,9 @@ GEM
171
183
  addressable (>= 2.3.6)
172
184
  crack (>= 0.3.2)
173
185
  hashdiff
174
- websocket-driver (0.6.5)
186
+ websocket-driver (0.7.1)
175
187
  websocket-extensions (>= 0.1.0)
176
- websocket-extensions (0.1.3)
188
+ websocket-extensions (0.1.4)
177
189
 
178
190
  PLATFORMS
179
191
  ruby
@@ -184,9 +196,10 @@ DEPENDENCIES
184
196
  cornucopia
185
197
  gem-release
186
198
  hashie
187
- rake (~> 10)
199
+ rake (~> 13)
188
200
  rspec
189
201
  rspec-rails
202
+ rspec_junit_formatter (~> 0.4.1)
190
203
  simplecov
191
204
  simplecov-rcov
192
205
  vcr
@@ -194,4 +207,4 @@ DEPENDENCIES
194
207
  yext-api!
195
208
 
196
209
  BUNDLED WITH
197
- 1.16.1
210
+ 1.17.3
data/README.md CHANGED
@@ -91,6 +91,39 @@ The global configurations can be initialized with ENV values. The following con
91
91
  Wether or not to use the Sandbox API endpoint or the API endpoint. This option cannot be set on a
92
92
  per-call basis. This option is ignored for all objects under the `LiveApi` namespace.
93
93
 
94
+ ### Events
95
+
96
+ Webhooks are implimented as ActiveSupport::Notifications.
97
+
98
+ You can hook into notifications in multiple ways:
99
+
100
+ ```ruby
101
+ # with a class:
102
+ class AddRequestChanged
103
+ def self.call(name, started, finished, unique_id, data)
104
+ params_hash = { name: name, started: started, finished: finished, unique_id: unique_id, data: data }
105
+ Rails.logger.error "add_request_changed called: #{params_hash}"
106
+ end
107
+ end
108
+
109
+ ActiveSupport::Notifications.subscribe "add_request.knowledge_manager.yext", AddRequestChanged
110
+
111
+ # with a block:
112
+ ActiveSupport::Notifications.subscribe "add_request.knowledge_manager.yext" do |name, started, finished, unique_id, data|
113
+ end
114
+ ```
115
+
116
+ The following notifications will be
117
+ instrumented with the indicated parameters:
118
+
119
+ * add_request.knowledge_manager.yext
120
+ * **meta** - The meta information for the webhook
121
+ * **add_request** - A Yext::Api::AdministrativeApi::AddRequest object of the changed AddRequest.
122
+
123
+ * listing.powerlistings.yext
124
+ * **meta** - The meta information for the webhook
125
+ * **listing** - A Yext::Api::KnowledgeApi::Powerlistings::Listing object of the changed Listing.
126
+
94
127
  ### General Usage
95
128
 
96
129
  The API namespaces are setup to mimic the structure of the Yext API documentation to make it easier
@@ -141,6 +174,7 @@ The following classes are planned based on that structure:
141
174
  * KnowledgeApi::AccountSettings::User
142
175
  * KnowledgeApi::AccountSettings::Account
143
176
  * KnowledgeApi::OptimizationTasks::OptimizationTask
177
+ * KnowledgeApi::OptimizationTasks::OptimizationLink
144
178
  * LiveApi::Menu
145
179
  * LiveApi::Bio
146
180
  * LiveApi::Product
@@ -162,12 +196,18 @@ end
162
196
 
163
197
  #### Fetching a single object
164
198
 
165
- Use `find`
199
+ Use `find` if you want to raise an exception if it cannot be found
166
200
 
167
201
  ```ruby
168
202
  account = Yext::Api::AdministrativeApi::Account.find("my-id")
169
203
  ```
170
204
 
205
+ Use `where(id: id).get` if you do not want an exception to be raised:
206
+
207
+ ```ruby
208
+ account = Yext::Api::AdministrativeApi::Account.where(id: "my-id").get
209
+ ```
210
+
171
211
  #### Overriding configuration options
172
212
 
173
213
  ```ruby
@@ -5,8 +5,11 @@ module Yext
5
5
  module Agreements
6
6
  # This controller processes Yext add_request webhook callbacks.
7
7
  #
8
- # The controller will call the add_request_changed function on the configured class
9
- # for the add_request_changed function.
8
+ # The controller will instrument the "add_request.knowledge_manager.yext" ActiveSupport Notification.
9
+ # The params hash will include:
10
+ # * meta - the `meta` value of the webhook.
11
+ # * add_request - a Yext::Api::AdministrativeApi::AddRequest object that is the AddRequest
12
+ # being reported on.
10
13
 
11
14
  # :webhooks:
12
15
  # :agreements:
@@ -19,59 +22,44 @@ module Yext
19
22
  extend Memoist
20
23
 
21
24
  def create
22
- process_add_request_changed
25
+ add_request = Yext::Api::AdministrativeApi::AddRequest.new(add_request_hash[:addRequest])
26
+
27
+ ActiveSupport::Notifications.instrument "add_request.knowledge_manager.yext",
28
+ meta: add_request_hash[:meta],
29
+ add_request: add_request do
30
+ # do your custom stuff here
31
+ end
23
32
 
24
33
  head :ok
25
34
  end
26
35
 
27
36
  private
28
37
 
29
- def process_add_request_changed
30
- processor = Yext::Api.configuration.get_callback_processor(:add_request_changed)
31
-
32
- return if processor.blank?
33
-
34
- processor.new(processor_args[:meta],
35
- Yext::Api::AdministrativeApi::AddRequest.new(processor_args[:addRequest]),
36
- nil).
37
- add_request_changed
38
- end
39
-
40
- def processor_args
41
- params_hash.convert_epoch :meta, :timestamp
42
- params_hash.convert_time :addRequest, :dateSubmitted
43
- params_hash.convert_time :addRequest, :dateCompleted
44
-
45
- params_hash.params
46
- end
47
-
48
38
  # rubocop:disable MethodLength
49
39
 
50
- def params_hash
51
- Yext::Api::Utils::Params.
52
- new(params.
53
- permit(meta: %i[eventType uuid timestamp accountId actor appSpecificAccountId],
54
- addRequest: [:id,
55
- :locationMode,
56
- :existingLocationId,
57
- :newLocationId,
58
- :newLocationAccountId,
59
- :newAccountParentAccountId,
60
- :newLocationData,
61
- { skus: [] },
62
- :agreementId,
63
- :status,
64
- :dateSubmitted,
65
- :dateCompleted,
66
- :statusDetail]).
67
- to_hash.
68
- with_indifferent_access)
40
+ def add_request_hash
41
+ params.
42
+ permit(meta: %i[eventType uuid timestamp accountId actor appSpecificAccountId],
43
+ addRequest: [:id,
44
+ :locationMode,
45
+ :existingLocationId,
46
+ :newLocationId,
47
+ :newLocationAccountId,
48
+ :newAccountParentAccountId,
49
+ :newLocationData,
50
+ { skus: [] },
51
+ :agreementId,
52
+ :status,
53
+ :dateSubmitted,
54
+ :dateCompleted,
55
+ :statusDetail]).
56
+ to_hash.
57
+ with_indifferent_access
69
58
  end
70
59
 
71
60
  # rubocop:enable MethodLength
72
61
 
73
- memoize :processor_args,
74
- :params_hash
62
+ memoize :add_request_hash
75
63
  end
76
64
  end
77
65
  end