class Courier::Profiles

Constants

KEY

Public Class Methods

new(session) click to toggle source
# File lib/trycourier/profiles.rb, line 5
def initialize(session)
  @session = session
end

Public Instance Methods

add(recipient_id:, profile:) click to toggle source
# File lib/trycourier/profiles.rb, line 27
def add(recipient_id:, profile:)
  replace(recipient_id: recipient_id, profile: profile)
end
get(recipient_id:) click to toggle source
# File lib/trycourier/profiles.rb, line 9
def get(recipient_id:)
  path = "#{KEY}/#{recipient_id}"
  res = @session.send(path, "GET")
  ErrorHandler.check_err(res)
end
get_subscriptions(recipient_id:, cursor: nil) click to toggle source
# File lib/trycourier/profiles.rb, line 15
def get_subscriptions(recipient_id:, cursor: nil)
  path = "#{KEY}/#{recipient_id}/subscriptions"

  params = {}
  if cursor
    params["cursor"] = cursor
  end

  res = @session.send(path, "GET", params: params)
  ErrorHandler.check_err(res)
end
merge(recipient_id:, profile:, idempotency_key: nil) click to toggle source
# File lib/trycourier/profiles.rb, line 42
def merge(recipient_id:, profile:, idempotency_key: nil)
  path = "#{KEY}/#{recipient_id}"
  payload = {
    'profile': profile
  }
  headers = {}
  if idempotency_key
    headers["Idempotency-Key"] = idempotency_key
  end
  res = @session.send(path, "POST", body: payload, headers: headers)
  ErrorHandler.check_err(res)
end
patch(recipient_id:, operations:) click to toggle source
# File lib/trycourier/profiles.rb, line 55
def patch(recipient_id:, operations:)
  path = "#{KEY}/#{recipient_id}"
  payload = {
    'patch': operations
  }
  res = @session.send(path, "PATCH", body: payload)
  ErrorHandler.check_err(res)
end
replace(recipient_id:, profile:) click to toggle source
# File lib/trycourier/profiles.rb, line 31
def replace(recipient_id:, profile:)
  path = "#{KEY}/#{recipient_id}"

  payload = {
    'profile': profile
  }

  res = @session.send(path, "PUT", body: payload)
  ErrorHandler.check_err_non_json(res)
end