Code Monkey home page Code Monkey logo

chargify2kiss's Introduction

Download chargify transactions and upload them to KissMetrics

Fetching from chargify

Downloading chargify transactions as json

export CHARGIFYAPIKEY=<zzzzz:x>
export CHARGIFYSUBDOMAIN=yoursubdomain
export CHARGIFYURL="https://${CHARGIFYAPIKEY}@${CHARGIFYSUBDOMAIN}.chargify.com"
export FLAGS='-s -H Accept:application/json -H Content-Type:application/json'

I drop these settings in .gitignored privateSettings.sh for testing.

source privateSettings.sh

Fetch transcations

curl ${FLAGS} -u ${CHARGIFYAPIKEY} https://${CHARGIFYSUBDOMAIN}.chargify.com/transactions |python -mjson.tool
or
curl ${FLAGS} ${CHARGIFYURL}/transactions.json |python -mjson.tool

You can qualify these with page,per_page,kinds[],since_date,until_date,since_id,max_id.

To lookup a subscription_id,

curl ${FLAGS} "${CHARGIFYURL}/subscriptions" |python -mjson.tool
# or lookup a specific transaction
curl ${FLAGS} "${CHARGIFYURL}/subscriptions/<subscription_id>" |python -mjson.tool

Node invocation

npm install # do this once
source privateSettings.sh
node chargify2kiss

Figure out how to do a while loop for paging. cache the subscription lookup.

Pushing to KissMetrics

do a get request to http://trk.kissmetrics.com/e

_kmq.push(['record', 'billed', {'Plan Type':'handle-1', 'Billing Amount':'1.00'}]);

http://trk.kissmetrics.com/e?Plan%20Type=handle-1&Billing%20Amount=1.00&_n=billed&_k=d2fb45441ee59b9e0e5fd42360be788b06a10b71&_p=daniel.lauzon%40gmail.com&_t=1330550219

From Kiss support: Ah, to actually use the _t value that you manually pass in, you also need to set _d=1

pushing to temp mongo

#start mongo
mongod --dbpath data --quiet --logpath /dev/null >/dev/null 2>&1 &
#stop monogo
echo "db.shutdownServer();" | mongo admin >/dev/null

#example max-aggreagtion in mongo-shell

db.users.find({},{_id:false,created:true}).forEach(printjson);
db.users.group({
    key: {},
    initial: {maxdate: 0},
    reduce: function(obj,agg){ if(obj.created>agg.maxdate) agg.maxdate=obj.created;},
    finalize: function(agg){ agg.stamp = new Date(agg.maxdate*1000) }
});

chargify2kiss's People

Contributors

daneroo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.