Skip to content

Commit

Permalink
Walking down town
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed May 29, 2019
0 parents commit 61aa40d
Show file tree
Hide file tree
Showing 9 changed files with 1,494 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/node_modules/
9 changes: 9 additions & 0 deletions Gemfile
@@ -0,0 +1,9 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

gem "amex", "~> 0.4.1"
25 changes: 25 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,25 @@
GEM
remote: https://rubygems.org/
specs:
amex (0.4.1)
httparty
nokogiri
httparty (0.17.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.0331)
mini_portile2 (2.4.0)
multi_xml (0.6.0)
nokogiri (1.10.3)
mini_portile2 (~> 2.4.0)

PLATFORMS
ruby

DEPENDENCIES
amex (~> 0.4.1)

BUNDLED WITH
2.0.1
23 changes: 23 additions & 0 deletions expronzo.rb
@@ -0,0 +1,23 @@
#!/usr/bin/env ruby
require 'amex'

class Expronzo
attr_reader :client

unless ENV['amexu'] and ENV['amexp']
raise "ur amex username and password must be available in" +
"the environmental variables 'amexu' and 'amexp'."
end

def initialize
@accounts = Amex::Client.
new(ENV['amexu'], ENV['amexp'])
.accounts

@accounts.each do |account|
puts account.transactions.inspect
end
end
end

Expronzo.new
26 changes: 26 additions & 0 deletions go.sh
@@ -0,0 +1,26 @@
#!/bin/bash
pot_id=pot_00009idHc715Uf9KcBiUMb
access_token=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJlYiI6IkpiMnhrdzVWNUh0WE1XMUd4bCtRIiwianRpIjoiYWNjdG9rXzAwMDA5akl2Z0RabjBjdERMOWtCeUciLCJ0eXAiOiJhdCIsInYiOiI1In0.3tZ2velWEi714dr5P2eleGG5BM6gMiCCjCyae4gg977KcBOcD1Y2F-YdjqocsKOOSHLEK2clMmI-eMstkCOEvg
account_id=acc_00009OeBcb40RrGoHJQAwD
dedupe_id=$RANDOM-lol
current_pot_value=$(http "https://api.monzo.com/pots" "Authorization: Bearer $access_token" | jq ".pots[] | select(.id==\"$pot_id\") | .balance")
echo "there's currently $current_pot_value in the amex pot"
current_balance=$(($(node index.js) * 100))
echo "the amex balance is $current_balance"
increase=$((current_balance - current_pot_value))
echo "that's an increase of $increase pennies"

if [ $increase -lt 1 ]; then
echo "that's less than a penny, so im doin nothin"
exit
fi

http --form PUT "https://api.monzo.com/pots/$pot_id/deposit" \
"Authorization: Bearer $access_token" \
"source_account_id=$account_id" \
"amount=$increase" \
"dedupe_id=$dedupe_id"

echo "transaction complete!!"
current_pot_value=$(http "https://api.monzo.com/pots" "Authorization: Bearer $access_token" | jq ".pots[] | select(.id==\"$pot_id\") | .balance")
echo "there's now $current_pot_value in the pot ^_^"
36 changes: 36 additions & 0 deletions index.js
@@ -0,0 +1,36 @@
let pup = require("puppeteer")

void (async function() {
let puppy = await pup.launch({ headless: false })
let bone = await puppy.newPage()
await bone.goto(
"https://global.americanexpress.com/login/en-GB?noRedirect=true&DestPage=%2Fdashboard"
)
await bone.waitForSelector(".eliloUserId input")
await bone.type(".eliloUserId input", "snootgirl22")
await bone.waitForSelector(".eliloPassword input")
await bone.type(".eliloPassword input", "magicfriend22")
await bone.click("[type=submit]")
await bone.waitForSelector(".summary-container")
await bone.waitForSelector(
"ul .undefined:nth-child(1) .value-link-inline-block"
)

let balanceElement = await bone.$(
"ul .undefined:nth-child(1) .value-link-inline-block .data-value"
)

let availableBalance = await bone.evaluate(
element => element.textContent,
balanceElement
)

let availableCredit = 3000

let currentBalance =
availableCredit - parseFloat(availableBalance.replace(/[^.0-9]/g, ""))

console.log(currentBalance)

await puppy.close()
})()
Binary file added lol.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 61aa40d

Please sign in to comment.