Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Updates for beta branch #1085

Merged
merged 7 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ on:
branches:
- master
- beta
- sdk-release/**
- feature/**
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches:
- master
- beta
- sdk-release/**
- feature/**

jobs:
build:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.5.0 - 2022-06-29
* [#1084](https://github.com/stripe/stripe-ruby/pull/1084) API Updates
* Add support for `deliver_card`, `fail_card`, `return_card`, and `ship_card` test helper methods on resource `Issuing.Card`
* [#1076](https://github.com/stripe/stripe-ruby/pull/1076) fix: Update logging to coerce ASCII-8BIT into UTF-8.

## 6.4.0 - 2022-06-17
* [#1073](https://github.com/stripe/stripe-ruby/pull/1073) API Updates
* Add support for `fund_cash_balance` test helper method on resource `Customer`
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v157
v161
80 changes: 80 additions & 0 deletions lib/stripe/resources/issuing/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,86 @@ def self.details(card, params = {}, opts = {})
opts: opts
)
end

def test_helpers
TestHelpers.new(self)
end

class TestHelpers < APIResourceTestHelpers
RESOURCE_CLASS = Card

def self.deliver_card(card, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/test_helpers/issuing/cards/%<card>s/shipping/deliver", { card: CGI.escape(card) }),
params: params,
opts: opts
)
end

def self.fail_card(card, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/test_helpers/issuing/cards/%<card>s/shipping/fail", { card: CGI.escape(card) }),
params: params,
opts: opts
)
end

def self.return_card(card, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/test_helpers/issuing/cards/%<card>s/shipping/return", { card: CGI.escape(card) }),
params: params,
opts: opts
)
end

def self.ship_card(card, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/test_helpers/issuing/cards/%<card>s/shipping/ship", { card: CGI.escape(card) }),
params: params,
opts: opts
)
end

def deliver_card(params = {}, opts = {})
@resource.request_stripe_object(
method: :post,
path: format("/v1/test_helpers/issuing/cards/%<card>s/shipping/deliver", { card: CGI.escape(@resource["id"]) }),
params: params,
opts: opts
)
end

def fail_card(params = {}, opts = {})
@resource.request_stripe_object(
method: :post,
path: format("/v1/test_helpers/issuing/cards/%<card>s/shipping/fail", { card: CGI.escape(@resource["id"]) }),
params: params,
opts: opts
)
end

def return_card(params = {}, opts = {})
@resource.request_stripe_object(
method: :post,
path: format("/v1/test_helpers/issuing/cards/%<card>s/shipping/return", { card: CGI.escape(@resource["id"]) }),
params: params,
opts: opts
)
end

def ship_card(params = {}, opts = {})
@resource.request_stripe_object(
method: :post,
path: format("/v1/test_helpers/issuing/cards/%<card>s/shipping/ship", { card: CGI.escape(@resource["id"]) }),
params: params,
opts: opts
)
end
end
end
end
end
9 changes: 9 additions & 0 deletions lib/stripe/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ def self.wrap_logfmt_value(val)
# Hopefully val is a string, but protect in case it's not.
val = val.to_s

# Some values returned by the server are encoded in ASCII-8BIT before
# being parsed as UTF-8 by Marshal. If we don't transform these here, then
# puts will fail as it tries to render UTF-8 characters as ASCII-8BIT
# which is not valid.
if val && val.encoding == Encoding::ASCII_8BIT
# Dup the string as it is a frozen literal.
val = val.dup.force_encoding("UTF-8")
end

if %r{[^\w\-/]} =~ val
# If the string contains any special characters, escape any double
# quotes it has, remove newlines, and wrap the whole thing in quotes.
Expand Down
Loading