1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

オンライン決済サービス Stripe の API を #Ruby の pry で叩いたら JSON が見にくいので pry-doc で色付けしてみたり curl + jq を使ったりと

Last updated at Posted at 2019-11-20

なんとAPI doc の例はそのまま使える一般公開のキーっぽい
https://stripe.com/docs/api/invoices/list?lang=ruby

install pry

gem install pry pry-doc

image

でも JSON みづらすぎ!

require 'stripe'
Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
Stripe::Invoice.list({limit: 3})

image

ハッシュなら色がつく

require 'stripe'
Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
Stripe::Invoice.list({limit: 3}).data.map(&:to_h)

image

curl + jq

Ruby関係ないよ
pryの起動も大変だよ

Docs で言語や curl への切り替えが可能。

image

curl の結果を jq にわたすと綺麗だね

brew install jq

curl -s https://api.stripe.com/v1/invoices -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: -d limit=3 -G | jq

image

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?