jzempel / stamps Goto Github PK
View Code? Open in Web Editor NEWStamps.com API for Python
License: Other
Stamps.com API for Python
License: Other
Have you done any testing using suds-jurko master codebase? Would allow for python 3 compatibility.
Per https://bitbucket.org/jurko/suds/issues/117/please-release-new-version Debian Sid and Fedora 24 used it for their release version of the package
'basestring' is no longer in python 3.0 and up.
Need to replace 'basestring' instances with 'str'.
Suds does not pull proxy information from environment variables. Per https://bitbucket.org/jurko/suds/issues/26/doesnt-work-behind-proxy it requires explicit proxy configuration.
As such, the BaseService should expose this here https://github.com/jzempel/stamps/blob/master/stamps/services.py#L87
It appears that postage amounts are represented with floats instead of decimals.
This might be a suds problem, but I figured it was important to at least mention this. Float results in rounding errors and should not be used for money.
Here is an example I just encountered -- Amount is 5.42, but it is shown as 5.4199999999999999 under the hood.
I discovered this because the decimal class raised a TypeError when it was fed the float.
If it is possible to use the decimal class, that would be prudent.
The formatting for the wsdl file:// url produces invalid url for me causing
URLError: <urlopen error [Error 3] The system cannot find the path specified: ''
See https://github.com/jzempel/stamps/blob/master/stamps/config.py#L71
self.wsdl = "file://{0}".format(wsdl)
This works for me: thenewguy@ea5f161
It would be nice to be to pass through kwargs supplied to the convenience methods. It is probably too much work to keep all of the kwargs up to date, but if kwargs are passed through as is then it doesn't require creating a subclass of the service to allow get_label to specify the image type or other less commonly used options.
Or something like this could be used to convert stamps camelcase to underscore notation with a map function for the option keys
import re
first_cap_re = re.compile('(.)([A-Z][a-z]+)')
all_cap_re = re.compile('([a-z0-9])([A-Z])')
def pythonify_stamps_key(key):
"""
THIS FUNCTION CONVERTS STAMPS.COM API CAMEL CASED
FIELD NAMES INTO PYTHONIC UNDERSCORED FIELD NAMES
"""
s1 = first_cap_re.sub(r'\1_\2', key)
return all_cap_re.sub(r'\1_\2', s1).lower()
A minor example that logs in, gets account info and creates a shipping label would be helpful.
Hello Jonathan,
I am trying to figure out how to get these work and hopefully you can shed some light on these.
def get_label(self, from_address, to_address, rate, transaction_id, sample=False):
return self.call("CreateIndicium", IntegratorTxID=transaction_id,
Rate=rate, From=from_address, To=to_address, SampleOnly=sample, memo='test order')
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.