New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial networking layer #5
Conversation
@momo-ozawa These tests are failing:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hiya! Overall this works really well! I left a couple comments below.
In addition the tests that are failing, I found the macOS example doesn't build because navigationBarItems
is for iOS only.
Also, I'm unsure we need to use Alamofire since the requests themselves are pretty simple, and we should be able to use URLSession's instead. Unless there was a specific reason you chose to use AF?
|
||
iapService.createOrder( | ||
identifier: product.productIdentifier, | ||
price: Int(truncating: product.price), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value of the price should be in cents, if the price is 5.99
then it should be converted to: 599
.
In theory this should work unless there's a better way:
Int(price.floatValue * 100)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. cd1fb1f
Thank you for updating the API docs as well! 🙇♀️
|
||
guard let appStoreReceiptURL = Bundle.main.appStoreReceiptURL, | ||
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) else { | ||
print("Could not find app store receipt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we handle the returns as errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! I'm thinking of creating a separate PR for error handling.
I think this PR might get big if I changed the CompletionCallbacks from (T) -> Void
to something like (Result<T, Error>) -> Void
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me!
"object": { | ||
"pins": [ | ||
{ | ||
"package": "Alamofire", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@momo-ozawa there's any special reason why we need Alamofire
?
I think it would be good to keep this library without dependencies and as much light as possible. Nowadays URLSession
is very powerful so I think we can go with it.
This can be refactored on a future PR though.
@momo-ozawa as we talked, let's ignore the failing tests for now and then we can get back to those later. |
For the purchased / restored tests to pass, we need to build a receipt stub and a mock iapService.
@leandroalonso @emilylaguna I'll be removing Alamofire in favor of URLSession in my next PR 🙇♀️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
Closing this PR due to merge conflicts -- I will create a new PR! |
Description
Resolves wordpress-mobile/WordPress-iOS#16863
This PR adds the initial networking layer:
InAppPurchasesService
to call the fetch product skus / create order endpointsInAppPurchasesServiceTests
InAppPurchasesAPIRouter
to organize the endpointsNotes
How to test
Configuration.storekit