~singpolyma/sgx-jmp

Pass customer_id through to leg2

The to in leg2 is not the phone number, but the fwd, which is not useful for
looking up customer.
Make sure from and to are in correct direction

Doesn't affect any current code paths, but should be correct in case we ever
start using it in the inbound case.

Also from does not have to be a formatted phone number, can be a string like
Anonymous, etc.
Pull in cdr_with_charge performance fix
Billing starts now
Load plans to db
We rely on this schema now
JSON route for outbound calls

For use from Asterisk
Try auto top up / low balance notify when not enough balance for a call

There is an edge case where a customer might not have auto-topped up yet but
they don't have enough balance for this call, so try to charge their card first
before telling them the call is a no go.
LowBalance returns amount added, if any
Also supports limits on inbound calls
Outbound call logic for overages

If cannot find an acceptable rate for the number, cannot call.
If balance is too low, cannot call.
If too close to limit, warn.
Else, call.
Add customer_id to outgoing call JSON
Support JSON route pre-limits

This will allow us to switch asterisk to the new logic before rolling out the
limits.  Asterisk will then support the limits once sgx-jmp begins instructing
it about them.
CustomerRepo::QueryKey and CustomerRepo#find_by_format

Introduce objects representing the different kind of query keys that can be used
to look up a customer.  These keys know how to use themselves to get
the (customer_id, jid) pair that is needed for an actual repo lookup.  All
find_by_* methods are now just trivial wrappers over these objects that pass on
to find_inner.

This enables the easy creation of a new helper: QueryKey.for, used as
find_by_format which allows passing an xmpp: URI, or a properly formatted tel,
or a customer id, and will find by the correct one.  This could cause a problem
if a customer id were to be a valid xmpp: URI or a formatted tel, so this method
does assume not using these formats for any customer id (which would be
ill-advised in any case).
End call on hangup
approved_domains unproxied
Fix typo, add test
Sometimes we get a list of errors, such as to LNP
Block messages over 3500/month

Generic error message to contact support.  No current customer will hit this
limit based on historical usage.
Next