welbesw / easypost-swift Goto Github PK
View Code? Open in Web Editor NEWA simple client library for the EasyPost API built in Swift
License: MIT License
A simple client library for the EasyPost API built in Swift
License: MIT License
Are you planning to update this to Swift 4? I may be able to update it and submit a pull request if you are unable to but I am by no means a Swift expert. Thanks ๐
Hi @welbesw,
I have submitted a pull request to include the Customs
information when creating the shipment request for international shipments. Can you please review and merge?
Hi There!
Been using this awesome framework for the last couple of weeks in testing. When I first set it up, everything worked great, rates were returning & I was able to but shipments no problem. Now, a few weeks later, the rates are always returning nil. All the rest seems to be uploading properly... Any idea why the change? Here's my code:
func createShipment(addressFrom : addressStruct, addressTo : addressStruct, productToShip : packageInfoStruct, completion : @escaping (_ result : NSError?) -> ()) {
let apiToken = "XXXXXXXXXXXXXX"
EasyPostApi.sharedInstance.setCredentials(apiToken, baseUrl: "https://api.easypost.com/v2/")
EasyPostApi.sharedInstance.postShipment(EasyPostAddress.init(jsonDictionary: addressTo.convertToAnyObject()!), fromAddress: EasyPostAddress.init(jsonDictionary: addressFrom.convertToAnyObject()!), parcel: EasyPostParcel.init(jsonDictionary: productToShip.convertToAnyObject()!)) { (shipment) in
DispatchQueue.main.async {
switch(shipment) {
case .success(let shipment):
print("Successfully posted shipment.")
if let id = shipment.id {
print(shipment.rates)
EasyPostApi.sharedInstance.buyShipment(id, rateId: (shipment.rates.first?.id)!, completion: { (response) in
print(response)
})
}
case .failure(let error):
print("Error posting shipment: \((error as NSError).localizedDescription)")
}
}
}
}
I put a print statement in your code to figure out what the JSON it's returning looks like :
...
"rates": <__NSArray0 0x1c400fe40>(
)
...
Any help would be greatly appreciated! This doesn't seem to be an issue with your code, more of an issue with something with EasyPost or myself, but I'd love some help if you can. Thanks! :]
It does not appear that this library currently implements shipment options per https://www.easypost.com/docs/api/#options. This leaves a lot of items unusable on shipments which should be present here. It'd be great if these were added.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.