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

送金サービス メール送金指示の修正 #66

Merged
merged 4 commits into from
Oct 16, 2023
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

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lib/gmo/const.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ module Const
:address_4 => "Address4",
:address_5 => "Address5",
:address_6 => "Address6",
:auth_code => "Auth_Code",
:auth_code_2 => "Auth_Code2",
:auth_code_3 => "Auth_Code3",
:amount => "Amount",
:bank_code => "Bank_Code",
:bank_id => "Bank_ID",
:branch_code => "Branch_Code",
:branch_code_jp => "Branch_Code_Jpbank",
:call_back_url => "Call_Back_Url",
:cancel_amount => "CancelAmount",
:cancel_tax => "CancelTax",
:card_name => "CardName",
Expand All @@ -52,6 +56,7 @@ module Const
:client_field_2 => "ClientField2",
:client_field_3 => "ClientField3",
:client_field_flg => "ClientFieldFlag",
:client_name => "Client_Name",
:commodity => "Commodity",
:confirm_base_date => "ConfirmBaseDate",
:continuance_month => "ContinuanceMonth",
Expand Down Expand Up @@ -87,6 +92,10 @@ module Const
:locale => "Locale",
:md => "MD",
:mail_address => "MailAddress",
:mail_template_free_1 => "Mail_Template_Free1",
:mail_template_free_2 => "Mail_Template_Free2",
:mail_template_free_3 => "Mail_Template_Free3",
:mail_template_number => "Mail_Template_Number",
:member_id => "MemberID",
:member_name => "MemberName",
:member_no => "MemberNo",
Expand Down Expand Up @@ -123,9 +132,11 @@ module Const
:register_disp_6 => "RegisterDisp6",
:register_disp_7 => "RegisterDisp7",
:register_disp_8 => "RegisterDisp8",
:remit_method_bank => "Remit_Method_Bank",
:reserve_no => "ReserveNo",
:ret_url => "RetURL",
:security_code => "SecurityCode",
:select_key => "Select_Key",
:seq_mode => "SeqMode",
:service_name => "ServiceName",
:service_tel => "ServiceTel",
Expand Down
13 changes: 12 additions & 1 deletion lib/gmo/remittance_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,17 @@ def search_balance(options = {})
# Mail_Deposit_Account_Name
# Expire
# Shop_Mail_Address
# Auth_Code
# Auth_Code2
# Auth_Code3
# Remit_Method_Bank
# Mail_Template_Free1
# Mail_Template_Free2
# Mail_Template_Free3
# Mail_Template_Number
# Bank_ID
# Select_Key
# Client_Name
### @return ###
# Method
# Amount
Expand All @@ -268,7 +279,7 @@ def search_balance(options = {})
def create_mail_deposit(options = {})
name = "/api/MailDepositRegistration.idPass"
options[:method] = 1
required = %i(deposit_id deposit_email amount deposit_account_name expire deposit_shop_email)
required = %i(deposit_id deposit_email amount expire deposit_shop_email)
assert_required_options(required, options)
post_request name, options
end
Expand Down
94 changes: 58 additions & 36 deletions spec/gmo/remittance_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,54 +376,76 @@
end

describe "#create_mail_deposit" do
let(:do_api_call) {
@service.create_mail_deposit({
:deposit_id => "dep00001",
:deposit_email => "[email protected]",
:amount => 1000,
:deposit_account_name => "An Yutzy",
:expire => 5,
:deposit_shop_email => "[email protected]"
})
}
subject(:do_api_call) { @service.create_mail_deposit(options) }

context 'with valid options', :vcr do
let(:options) do
{
:deposit_id => "dep00001",
:deposit_email => "[email protected]",
:amount => 1000,
:deposit_account_name => "An Yutzy",
:expire => 5,
:deposit_shop_email => "[email protected]",
:auth_code => "auth00001",
:auth_code_2 => "auth00002",
:auth_code_3 => "auth00003",
:remit_method_bank => "1",
:mail_template_free_1 => "mail_template_free_1",
:mail_template_free_2 => "mail_template_free_2",
:mail_template_free_3 => "mail_template_free_3",
:mail_template_number => 1,
:bank_id => "bank_id00001",
:select_key => "select00001",
:client_name => "イライニンタロウ",
}
end

it "gets data about a mail deposit", :vcr do
result = do_api_call
result["Deposit_ID"].nil?.should_not be_truthy
result["Method"].nil?.should_not be_truthy
result["Amount"].nil?.should_not be_truthy
result["Expire"].nil?.should_not be_truthy
end
before { allow(GMO).to receive(:make_request).and_call_original }

context 'with all required options' do
let(:response) { OpenStruct.new(status: 200, body: nil ) }
before { allow(GMO).to receive(:make_request) { response } }
it "gets data about a mail deposit" do
result = do_api_call
expect(result["Deposit_ID"]).to eq options[:deposit_id]
expect(result["Method"]).to eq "1"
expect(result["Amount"]).to eq options[:amount].to_s
expect(result["Expire"]).not_to be_nil
end

it "makes request with correct parameters", :vcr do
it "makes request with correct parameters" do
do_api_call
path = "/api/MailDepositRegistration.idPass"
args = {
"Deposit_ID" => "dep00001",
"Mail_Address" => "[email protected]",
"Amount" => 1000,
"Mail_Deposit_Account_Name" => "An Yutzy",
"Expire" => 5,
"Shop_Mail_Address" => "[email protected]",
"Deposit_ID" => options[:deposit_id],
"Mail_Address" => options[:deposit_email],
"Amount" => options[:amount],
"Mail_Deposit_Account_Name" => options[:deposit_account_name],
"Expire" => options[:expire],
"Shop_Mail_Address" => options[:deposit_shop_email],
"Auth_Code" => options[:auth_code],
"Auth_Code2" => options[:auth_code_2],
"Auth_Code3" => options[:auth_code_3],
"Remit_Method_Bank" => options[:remit_method_bank],
"Mail_Template_Free1" => options[:mail_template_free_1],
"Mail_Template_Free2" => options[:mail_template_free_2],
"Mail_Template_Free3" => options[:mail_template_free_3],
"Mail_Template_Number" => options[:mail_template_number],
"Bank_ID" => options[:bank_id],
"Select_Key" => options[:select_key],
"Client_Name" => options[:client_name],
"Method" => 1,
"Shop_ID" => @service.shop_id,
"Shop_Pass" => @service.shop_pass
}
verb = "post"
options = { :host => @service.host }
expect(GMO).to receive(:make_request).with(path, args, verb, options)
expect(GMO).to have_received(:make_request).with(path, args, "post", { :host => @service.host })
end

after { do_api_call }
end

it "got error if missing options", :vcr do
lambda {
result = @service.create_mail_deposit()
}.should raise_error("Required deposit_id, deposit_email, amount, deposit_account_name, expire, deposit_shop_email were not provided.")
context "with invalid options" do
let(:options) { {} }

it "got error" do
expect { do_api_call }.to raise_error("Required deposit_id, deposit_email, amount, expire, deposit_shop_email were not provided.")
end
end
end

Expand Down