/CataGengo

A demo of the myGengo API on the Catalyst web framework

Primary LanguagePerl

Description

This is a demo app built on the perl web framework: Catalyst.

It flexes many aspects of the myGengo API and can be used for local (mock) testing as well as sandbox access.

The app is based on the WebService::MyGengo API library and the Catalyst::Model::WebService::MyGengo module.

Installation

Assumptions

  1. You have access to a browser supported by jQuery
  2. You are installing on a UNIX-like environment
  3. You have perl 5.10.1+ installed
  4. You are using local::lib, or you don't mind if Catalyst installs a bunch of perl modules on your system.
  • If you have questions about any of the above, drop me a line!

Steps

  1. Install cpanminus
  • This is a great package installer that should make the rest of the installation much smoother
  • If you are asked whether to install a dependency, always answer yes
  • cpan -i App::cpanminus
  1. Download and install CataGengo
  • wget -O - 'https://github.com/nheinric/CataGengo/tarball/master' | tar xz -
  • cd nheinric-* && cpanm --installdeps .
  • perl Makefile.PL && make && make test
  • NOTE: make install is not necessary!
  1. Done!

Running the App

Mock Mode

In mock mode, all requests will be handled by a local object that mimics the action of the sandbox.

No requests to the real sandbox will be made, so you can test to your heart's content without worrying about throttling.

However, if you stop/start the server, all of your test Jobs will vanish.

  1. Run the local server:
  • CATAGENGO_HOME=. ./script/catagengo_server.pl -d
  1. Open http://127.0.0.1:3000/mygengo in your browser of choice
  2. Click the 'Create a New Job' tab to make a Job
  3. Test to your heart's content!
  • Note: your credits in the 'Account' tab will not decrease. This is considered a feature, as you can test forever!

Sandbox Mode

If you make a lot of requests the sandbox may begin to throttle you (which manifests as all requests resulting in an "authentication didn't pass" error.)

If this happens you'll need to wait awhile (not sure how long...) until you can test again.

  1. Open catagengo.conf. It will look like the following:

    <Model::MyGengo>
    #    class           WebService::MyGengo::Client
        class           CataGengo::Test::Util::Client
        public_key      pubkey
        private_key     privkey
        use_sandbox     1
    </Model::MyGengo>
    
  2. Swap the commented class lines so they look like this:

    <Model::MyGengo>
        class           WebService::MyGengo::Client
    #    class           CataGengo::Test::Util::Client
        public_key      pubkey
        private_key     privkey
        use_sandbox     1
    </Model::MyGengo>
    
  3. Replace 'pubkey' and 'privkey' with your sandbox API public and private keys

  • If you have any "#" characters in your keys, you must escape them with a backslash: \#
  1. Save the file and run the local server:
  • CATAGENGO_HOME=. ./script/catagengo_server.pl -d
  1. Open http://127.0.0.1:3000/mygengo in your browser of choice
  2. Click the 'Jobs' tab to view your Jobs in the sandbox
  • If you have a lot of Jobs, the page will take awhile to load the first time
  • Subsequent loads will be quicker because the Job list is cached internally
  • If you update a Job in the sandbox, open the Job list or Job details click the 'Refresh Data' button to refresh data from the API

Live Mode

Live mode works exactly like Sandbox mode, only you'll be interacting with the production myGengo server.

YOU WILL BE CHARGED FOR NEW JOBS CREATED IN THIS MODE!

  1. Open catagengo.conf again and:
  2. Change your public/private keys to your production API keys
  3. Change use_sandbox to 0
  4. Save the file and run the local server:
  • CATAGENGO_HOME=. ./script/catagengo_server.pl -d

Support

Feel free to contact me at nheinric-at-cpan.org if you hit any snags!