Method: FeatureFlagMonitor.bulk_write

Defined in:
lib/feature_flag_monitor.rb

.bulk_write(flags:, domains: nil, cohort: nil, exceptions: {}, authorization:) ⇒ Object

Raises:

  • (ArgumentError)


117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/feature_flag_monitor.rb', line 117

def self.bulk_write(flags:, domains: nil, cohort: nil, exceptions: {}, authorization:)
  raise ArgumentError, 'Must provide either domains or cohort.' if domains.nil? && cohort.nil?

  headers = {
    'X-Socrata-RequestId' => request_id,
    'Content-Type' => 'application/json',
  }.merge(authorization).compact

  payload = {
    flags: flags,
    domains: domains,
    cohort: cohort,
    except: exceptions
  }
  HTTParty.send(:patch, URI.join(FFM, bulk_endpoint), body: payload.to_json, headers: headers).
    tap(&method(:raise_errors_on_non_success))
end