This file contains hidden or 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
| local lpeg = require'lpeg' | |
| local P, R, S = lpeg.P, lpeg.R, lpeg.S --patterns | |
| local C, Ct = lpeg.C, lpeg.Ct --capture | |
| local V = lpeg.V --variable | |
| local parser = P { | |
| 'program', -- initial rule | |
| program = Ct(V'sexpr' ^ 0), | |
| wspace = S' \n\r\t' ^ 0, | |
| atom = V'boolean' + V'integer' + V'string' + V'symbol', |
This file contains hidden or 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
| -- OAuth Request 生成 | |
| oauthRequest :: OAuth -> String -> String -> [Parameter] -> IO String | |
| oauthRequest oauth url token parameter = do | |
| timestamp <- show . (\(TOD i _) -> i) <$> getClockTime -- タイムスタンプ取得 | |
| nonce <- show <$> randomRIO (0, maxBound::Int) -- 乱数取得 | |
| let authorizationParameters_ = parameter ++ [ | |
| ("oauth_consumer_key", consumerKey oauth), | |
| ("oauth_nonce", nonce), | |
| ("oauth_timestamp", timestamp), | |
| ("oauth_signature_method", "HMAC-SHA1"), |
This file contains hidden or 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
| // Make Optional a monad | |
| extension Optional { | |
| // Scala style, define `flatMap` directly | |
| func flatMap<U>(f: (a: T) -> Optional<U>) -> Optional<U> { | |
| switch (self) { | |
| case .None: return nil | |
| case .Some(let value): return f(a: value) | |
| } | |
| } | |
This file contains hidden or 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
| // Swift Monads -- Maybe | |
| // Juan C. Montemayor (@norsemelon) | |
| // This operator can be used to chain Optional types like so: | |
| // optionalVal >>= f1 >>= f2 | |
| // where f1 and f2 have type `Any -> Any?` | |
| // | |
| // If a value is ever nil, the chain short-circuits and will result in nil. | |
| // This is a much neater way to do this than using the if syntax specified in | |
| // the Swift iBook. |
This file contains hidden or 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
| curl -X PUT "https://api.cancapital.com/pq/:application_id/options/:option_id" \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Basic $HASH" \ | |
| -m 30 \ | |
| -v \ | |
| # Empty 200 response on success |
This file contains hidden or 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
| curl -X GET "https://api.cancapital.com/status/:application_id" \ | |
| -H "Authorization: Basic $HASH" \ | |
| -H "Content-Type: application/json" \ | |
| -m 30 \ | |
| -v \ |
This file contains hidden or 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
| curl -X POST "https://api.cancapital.com/pq" \ | |
| -H "Content-Type: application/json" \ | |
| -H "Authorization: Basic $HASH" \ | |
| -m 30 \ | |
| -d ' | |
| { | |
| "can_auth_to_pull_credit": true, | |
| "can": { | |
| "partner_id": 1, | |
| "products": [ |
This file contains hidden or 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
| curl -i -X POST "http://canconnect-sandbox.herokuapp.com/iq" \ | |
| -H "ACCEPT: application/json" \ | |
| -H "CONTENT_TYPE: application/json" \ | |
| -H "Authorization: Basic $HASH" \ | |
| -m 30 \ | |
| -d ' | |
| { | |
| "operationPurpose" : "expansion", | |
| "requestedAmount" : 100000, | |
| "creditScoreLowerBound" : 750, |