Skip to content

Update library to use Phaxio API to use v2.1 - #23

Merged
jnankin merged 1 commit into
masterfrom
22-update-to-api-2-1
Aug 29, 2018
Merged

jnankin merged 1 commit into
masterfrom
22-update-to-api-2-1

Conversation

@noelherrick

@noelherrick noelherrick commented Aug 3, 2018

Copy link
Copy Markdown
Collaborator

Phaxio has released a new API, so we need to update this client library to support those changes. There are three major updates: a new endpoint, removing parameters from the fax callback, and moving to HTTP Basic Authorization.

  1. We're going to use a new endpoint for the library (a different version string). Only the tests needed to be rewritten for this change besides changing the String in the Phaxio class.

  2. The callback example project needed to remove success, is_test, and direction from the expected parameters.

  3. We needed to move to HTTP Basic Authorization. The RestClient accommodated this change, but called it Authentication, so I renamed the classes/methods from using the word authentication to authorization, and then changed the Phaxio class to use basic auth on the RestClient. This necessitated a bunch of changes to the tests that mocked the HTTP endpoints which is the majority of the lines in this commit.

Finally, a couple of minor changes: a previous PR didn't space parameters in method signatures and calls, so there are a few lines that just adding spaces. Secondly, barcodes (an array of ints) and callerName (a String) were added the Fax objects in the client and the example project.

Closes #22

@noelherrick noelherrick self-assigned this Aug 3, 2018
@@ -1,10 +1,10 @@
package com.phaxio.restclient;

public class BasicAuthentication {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTP calls this Authorization, not Authentication.

dos.flush();
dos.close();
} else {
} else if (!request.parameters.isEmpty()) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were always sending at least the authorization parameters, so this client never had to deal with an empty body. This allows that.

String json = Responses.json("/account_status.json");

stubFor(get(urlEqualTo("/v2/account/status?api_secret=SECRET&api_key=KEY"))
stubFor(get(urlEqualTo("/ver/account/status"))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the version string isn't really important, I'm just faking it with the placeholder ver which would allow us to change versions but not update all these places in the tests.

@noelherrick
noelherrick force-pushed the 22-update-to-api-2-1 branch from 3684280 to 500e555 Compare August 3, 2018 11:49
Phaxio has released a new API, so we need to update this client library to
support those changes. There are three major updates: a new endpoint,
removing parameters from the fax callback, and moving to HTTP Basic
Authorization.

1) We're going to use a new endpoint for the library (a different version
string). Only the tests needed to be rewritten for this change besides
changing the String in the Phaxio class.

2) The callback example project needed to remove `success`, `is_test`,
and `direction` from the expected parameters.

3) We needed to move to HTTP Basic Authorization. The RestClient
accomodated this change, but called it Authentication, so I renamed
the classes/methods from using the word authentication to authorization,
and then changed the Phaxio class to use basic auth on the RestClient.
This necessitated a bunch of changes to the tests that mocked the HTTP
endpoints which is the majority of the lines in this commit.

Finally, a couple of minor changes: a previous PR didn't space parameters
in method signatures and calls, so there are a few lines that just adding
spaces. Secondly, barcodes (an list of objects) and callerName (a String)
were added the Fax objects in the client and the example project.
@noelherrick
noelherrick force-pushed the 22-update-to-api-2-1 branch from 500e555 to acca6b6 Compare August 10, 2018 10:01
@jnankin
jnankin merged commit bd6d3a7 into master Aug 29, 2018
@noelherrick
noelherrick deleted the 22-update-to-api-2-1 branch January 21, 2019 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants