Class: Notifications::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/notifications/client.rb,
lib/notifications/client/speaker.rb,
lib/notifications/client/version.rb,
lib/notifications/client/notification.rb,
lib/notifications/client/request_error.rb,
lib/notifications/client/response_notification.rb,
lib/notifications/client/notifications_collection.rb

Defined Under Namespace

Classes: Notification, NotificationsCollection, RequestError, ResponseNotification, Speaker

Constant Summary collapse

PRODUCTION_BASE_URL =
"https://api.notifications.service.gov.uk".freeze
VERSION =
"1.0.0".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Client

Returns a new instance of Client.



20
21
22
# File 'lib/notifications/client.rb', line 20

def initialize(*args)
  @speaker = Speaker.new(*args)
end

Instance Attribute Details

#speakerObject (readonly)

Returns the value of attribute speaker.



10
11
12
# File 'lib/notifications/client.rb', line 10

def speaker
  @speaker
end

Instance Method Details

#get_notification(id) ⇒ Notification

Parameters:

  • id (String)

Returns:

See Also:



46
47
48
49
50
# File 'lib/notifications/client.rb', line 46

def get_notification(id)
  Notification.new(
    speaker.get(id)
  )
end

#get_notifications(options = {}) ⇒ NotificationsCollection

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :template_type (String)

    sms or email

  • :status (String)

    sending, delivered, permanently failed, temporarily failed, or technical failure

  • :page (String)
  • :page_size (String)
  • :limit_days (String)

Returns:

See Also:



64
65
66
67
68
# File 'lib/notifications/client.rb', line 64

def get_notifications(options = {})
  NotificationsCollection.new(
    speaker.get(nil, options)
  )
end

#send_email(args) ⇒ ResponseNotification

 @see Notifications::Client::Speaker#post



27
28
29
30
31
# File 'lib/notifications/client.rb', line 27

def send_email(args)
  ResponseNotification.new(
    speaker.post("email", args)
  )
end

#send_sms(args) ⇒ ResponseNotification



36
37
38
39
40
# File 'lib/notifications/client.rb', line 36

def send_sms(args)
  ResponseNotification.new(
    speaker.post("sms", args)
  )
end