-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rakefile
59 lines (47 loc) · 1.73 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true
require "reek/rake/task"
require "rspec/core/rake_task"
require "rubocop/rake_task"
require "bump/tasks"
Reek::Rake::Task.new do |reek|
reek.fail_on_error = true
end
RuboCop::RakeTask.new
RSpec::Core::RakeTask.new(:spec) do |rspec|
rspec.verbose = false
end
task test: :spec
task default: %i[rubocop reek spec]
desc "Export the Zuora Schema using the Describe API"
task :export_schema do
setup_iron_bank
IronBank::Schema.export
end
desc "Query Zuora for fields that we should not use in a query"
task :excluded_fields, [:filename] do |_t, args|
require "psych"
setup_iron_bank
destination = args[:filename] || IronBank.configuration.excluded_fields_file
# NOTE: In some instances the error message from Zuora will not include the
# unqueryable fields that need to be excluded. When that happens IronBank's
# strategy will be to perform a binary search through the fields listed in the
# query -- at the cost of performance due to repeated requests sent to Zuora
# as it tries to identify the offending field.
#
# See:
# - https://github.com/zendesk/iron_bank/pull/107
fields = IronBank::Schema.excluded_fields.sort.to_h
File.write(destination, Psych.dump(fields))
end
# Helper function to set up an `IronBank::Client` instance
def setup_iron_bank
require "dotenv/load"
require "iron_bank"
IronBank.configure do |config|
config.client_id = ENV.fetch("ZUORA_CLIENT_ID", nil)
config.client_secret = ENV.fetch("ZUORA_CLIENT_SECRET", nil)
config.auth_type = ENV.fetch("ZUORA_AUTH_TYPE", "token")
config.domain = ENV.fetch("ZUORA_DOMAIN", nil)
config.excluded_fields_file = ENV.fetch("ZUORA_EXCLUDED_FIELDS_FILE", nil)
end
end