Created
March 4, 2014 14:46
-
-
Save theinventor/9347744 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We need a new library built :) | |
We use cloudprint for printing, the current library was designed incredibly poorly. | |
It uses globals and we have print jobs going to the wrong user when we use multi-threaded workers. | |
We need it to be instance based, so when you get an instance using the Class.new method, the credentials are contained there in the instance - not globals. | |
Old library: | |
https://github.com/minciue/cloudprint | |
Example gists that we use to get the auth credentials: | |
omniauth.rb https://gist.github.com/theinventor/9220901 | |
sessions_controller.rb https://gist.github.com/theinventor/9220893 | |
We need a new library built, it needs to be a gem, we will open-source it - so please do not put any credentials in it. | |
It should have the same interface except for the setup. | |
Example, currently to set it up: | |
CloudPrint.setup( | |
refresh_token: 'refresh_token', | |
client_id: 'client_id', | |
client_secret: 'client_secret', | |
callback_url: 'callback_url' | |
) | |
change that to: | |
@client = CloudPrint.new( | |
refresh_token: 'refresh_token', | |
client_id: 'client_id', | |
client_secret: 'client_secret', | |
callback_url: 'callback_url' | |
) | |
Then instead of | |
printers = CloudPrint::Printer.all # this will return a list of printers. | |
my_printer = CloudPrint::Printer.find('printer_id') # this will get a printer with a specific id. | |
my_printer.print(content: "<h1>Hello World</h1>") # the :content option can also take a File object as a parameter, CloudPrint accepts HTML and PDF files. | |
It should work like; | |
printers = @client.printers.all # this will return a list of printers. | |
my_printer = @client.printers.find('printer_id') # this will get a printer with a specific id. | |
my_printer.print(content: "<h1>Hello World</h1>") # the :content option can also take a File object as a parameter, CloudPrint accepts HTML and PDF files. | |
I hope that makes sense.. | |
Feel free to borrow as much code as needed from that library, and leave them credit where needed. | |
We should have a call after you take a look and see how many hours you think this will take. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment