Module: Office365::REST::Subscription

Included in:
API
Defined in:
lib/office365/rest/subscription.rb

Instance Method Summary collapse

Instance Method Details

#create_subscription(args = {}) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/office365/rest/subscription.rb', line 6

def create_subscription(args = {})
  raise ArgumentError, "Missing changeType" if args[:changeType].nil?
  raise ArgumentError, "Missing notificationUrl" if args[:notificationUrl].nil?
  raise ArgumentError, "Missing resource" if args[:resource].nil?
  raise ArgumentError, "Missing expirationDateTime" if args[:expirationDateTime].nil?
  raise ArgumentError, "Missing clientState" if args[:clientState].nil?

  Models::Subscription.new(
    Request.new(access_token, debug: debug).post("/v1.0/subscriptions", { json_header: true }.merge(args))
  )
end

#renew_subscription(args = {}) ⇒ Object

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
# File 'lib/office365/rest/subscription.rb', line 18

def renew_subscription(args = {})
  raise ArgumentError, "Missing subscription identifier" if args[:identifier].nil?

  identifier = args.delete(:identifier)

  Models::Subscription.new(
    Request.new(access_token, debug: debug).patch("/v1.0/subscriptions/#{identifier}", { json_header: true }.merge(args))
  )
end