Skip to content

Commit

Permalink
Merge pull request #143 from alphagov/chore/joy/update-client
Browse files Browse the repository at this point in the history
chore: update ruby client to include new fields: is_cost_data_ready, cost_in_pounds and cost_details
  • Loading branch information
joybytes authored Jul 31, 2024
2 parents dea03d6 + 072e18f commit b12fe69
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 16 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 6.2.0
* Added fields related to cost data in response:
* `is_cost_data_ready`: This field is true if cost data is ready, and false if it isn't (Boolean).
* `cost_in_pounds`: Cost of the notification in pounds. The cost does not take free allowance into account (Float).
* `cost_details.billable_sms_fragments`: Number of billable SMS fragments in your text message (SMS only) (Integer).
* `cost_details.international_rate_multiplier`: For international SMS rate is multiplied by this value (SMS only) (Integer).
* `cost_details.sms_rate`: Cost of 1 SMS fragment (SMS only) (Float).
* `cost_details.billable_sheets_of_paper`: Number of sheets of paper in the letter you sent, that you will be charged for (letter only) (Integer).
* `cost_details.postage`: Postage class of the notification sent (letter only) (String).

## 6.1.0

* Adds a `one_click_unsubscribe_url` parameter to `send_email` so services can allow users to easily unsubscribe from distribution lists.
Expand Down
3 changes: 3 additions & 0 deletions lib/notifications/client/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class Notification
completed_at
created_by_name
one_click_unsubscribe_url
cost_in_pounds
is_cost_data_ready
cost_details
).freeze

attr_reader(*FIELDS)
Expand Down
2 changes: 1 addition & 1 deletion lib/notifications/client/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

module Notifications
class Client
VERSION = "6.1.0".freeze
VERSION = "6.2.0".freeze
end
end
7 changes: 7 additions & 0 deletions spec/factories/client_notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
"sent_at" => "2016-11-29T11:12:40.12354Z",
"completed_at" => "2016-11-29T11:12:52.12354Z",
"created_by_name" => "A. Sender",
"is_cost_data_ready" => true,
"cost_in_pounds" => 0.5,
"cost_details" => {
"billable_sms_fragments" => 1,
"international_rate_multiplier" => 1.0,
"sms_rate" => 0.05
}
}
end
end
Expand Down
22 changes: 7 additions & 15 deletions spec/notifications/client/get_notification_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
describe Notifications::Client do
let(:client) { build :notifications_client }

let(:uri) {
URI.parse(Notifications::Client::PRODUCTION_BASE_URL)
}
let(:uri) { URI.parse(Notifications::Client::PRODUCTION_BASE_URL) }

describe "get a notification by id" do
before do
Expand All @@ -13,17 +10,9 @@
).to_return(body: mocked_response.to_json)
end

let(:id) {
"1"
}

let!(:notification) {
client.get_notification(id)
}

let(:mocked_response) {
attributes_for(:client_notification)[:body]
}
let(:id) { "1" }
let!(:notification) { client.get_notification(id) }
let(:mocked_response) { attributes_for(:client_notification)[:body] }

it "expects notification" do
expect(notification).to be_a(
Expand All @@ -43,6 +32,9 @@
sent_at
completed_at
created_by_name
cost_in_pounds
is_cost_data_ready
cost_details
).each do |field|
it "expect to include #{field}" do
expect(
Expand Down

0 comments on commit b12fe69

Please sign in to comment.