From 7ed9f27cbca20df1d6b53d0f1aa982f1f3bf3a40 Mon Sep 17 00:00:00 2001 From: BlockChyp SDK Builder Date: Tue, 24 Oct 2023 22:01:24 +0000 Subject: [PATCH] added merchant statement apis --- README.md | 67 +++++++++++++++++++ .../MerchantInvoiceDetailExample.m | 22 ++++++ .../MerchantInvoiceDetailExample.swift | 20 ++++++ blockchyp-ios/BlockChyp/BlockChyp.h | 3 + blockchyp-ios/BlockChyp/BlockChyp.m | 7 ++ .../Tests/MerchantInvoiceDetailTest.m | 66 ++++++++++++++++++ 6 files changed, 185 insertions(+) create mode 100644 blockchyp-ios-examples/MerchantInvoiceDetailExample.m create mode 100644 blockchyp-ios-examples/MerchantInvoiceDetailExample.swift create mode 100644 blockchyp-ios/Tests/MerchantInvoiceDetailTest.m diff --git a/README.md b/README.md index 8b37233..acb506e 100644 --- a/README.md +++ b/README.md @@ -6813,6 +6813,73 @@ class ExampleClass { +#### Merchant Invoice Detail + + + +* **API Credential Types:** Partner +* **Required Role:** Partner API Access + +The API returns detailed information about a specific merchant statement. + + + +##### From Objective-C: + +```objective-c +#import +#import + +int main (int argc, const char * argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + BlockChyp *client = [[BlockChyp alloc] + initWithApiKey:@"SPBXTSDAQVFFX5MGQMUMIRINVI" + bearerToken:@"7BXBTBUPSL3BP7I6Z2CFU6H3WQ" + signingKey:@"bcae3708938cb8004ab1278e6c0fcd68f9d815e1c3c86228d028242b147af58e"]; + + NSMutableDictionary *request = [[NSMutableDictionary alloc] init]; + [client merchantInvoiceDetailWithRequest:request handler:^(NSDictionary *request, NSDictionary *response, NSError *error) { + NSNumber *success = [response objectForKey:@"success"]; + if (success.boolValue) { + NSLog(@"Success"); + } + }]; + [pool drain]; + return 0; +} + +``` + +##### From Swift: + +```swift +import BlockChyp + +class ExampleClass { + + func example() { + let client = BlockChyp.init( + apiKey: "ZN5WQGX5PN6BE2MF75CEAWRETM", + bearerToken: "SVVHJCYVFWJR2QKYKFWMZQVZL4", + signingKey: "7c1b9e4d1308e7bbe76a1920ddd9449ce50af2629f6bb70ed3c110365935970b" + ) + + var request: [String:Any] = [:] + client.merchantInvoiceDetail(withRequest: request, handler: { (request, response, error) in + let approved = response["success"] as? Bool + if (approved.unsafelyUnwrapped) { + NSLog("Success") + } + }) + } + + +``` + + + #### Partner Statement Detail diff --git a/blockchyp-ios-examples/MerchantInvoiceDetailExample.m b/blockchyp-ios-examples/MerchantInvoiceDetailExample.m new file mode 100644 index 0000000..946a90a --- /dev/null +++ b/blockchyp-ios-examples/MerchantInvoiceDetailExample.m @@ -0,0 +1,22 @@ +#import +#import + +int main (int argc, const char * argv[]) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + BlockChyp *client = [[BlockChyp alloc] + initWithApiKey:@"SPBXTSDAQVFFX5MGQMUMIRINVI" + bearerToken:@"7BXBTBUPSL3BP7I6Z2CFU6H3WQ" + signingKey:@"bcae3708938cb8004ab1278e6c0fcd68f9d815e1c3c86228d028242b147af58e"]; + + NSMutableDictionary *request = [[NSMutableDictionary alloc] init]; + [client merchantInvoiceDetailWithRequest:request handler:^(NSDictionary *request, NSDictionary *response, NSError *error) { + NSNumber *success = [response objectForKey:@"success"]; + if (success.boolValue) { + NSLog(@"Success"); + } + }]; + [pool drain]; + return 0; +} diff --git a/blockchyp-ios-examples/MerchantInvoiceDetailExample.swift b/blockchyp-ios-examples/MerchantInvoiceDetailExample.swift new file mode 100644 index 0000000..27d6c21 --- /dev/null +++ b/blockchyp-ios-examples/MerchantInvoiceDetailExample.swift @@ -0,0 +1,20 @@ +import BlockChyp + +class ExampleClass { + + func example() { + let client = BlockChyp.init( + apiKey: "ZN5WQGX5PN6BE2MF75CEAWRETM", + bearerToken: "SVVHJCYVFWJR2QKYKFWMZQVZL4", + signingKey: "7c1b9e4d1308e7bbe76a1920ddd9449ce50af2629f6bb70ed3c110365935970b" + ) + + var request: [String:Any] = [:] + client.merchantInvoiceDetail(withRequest: request, handler: { (request, response, error) in + let approved = response["success"] as? Bool + if (approved.unsafelyUnwrapped) { + NSLog("Success") + } + }) + } + diff --git a/blockchyp-ios/BlockChyp/BlockChyp.h b/blockchyp-ios/BlockChyp/BlockChyp.h index a1a5ed9..0cf3d1b 100644 --- a/blockchyp-ios/BlockChyp/BlockChyp.h +++ b/blockchyp-ios/BlockChyp/BlockChyp.h @@ -141,6 +141,9 @@ NS_ASSUME_NONNULL_BEGIN // Returns a list of merchant invoices. -(void)merchantInvoicesWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler; +// Returns detail for a single merchant-invoice statement. +-(void)merchantInvoiceDetailWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler; + // Returns detail for a single partner statement. -(void)partnerStatementDetailWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler; diff --git a/blockchyp-ios/BlockChyp/BlockChyp.m b/blockchyp-ios/BlockChyp/BlockChyp.m index 50ccf3e..9b28672 100644 --- a/blockchyp-ios/BlockChyp/BlockChyp.m +++ b/blockchyp-ios/BlockChyp/BlockChyp.m @@ -294,6 +294,13 @@ -(void)merchantInvoicesWithRequest:(NSDictionary *)request handler:(BlockChypCom } +// Returns detail for a single merchant-invoice statement. +-(void)merchantInvoiceDetailWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler { + + [self routeGatewayRequestWith:request path:@"/api/merchant-invoice-detail" method:@"POST" handler:handler]; + +} + // Returns detail for a single partner statement. -(void)partnerStatementDetailWithRequest:(NSDictionary *)request handler:(BlockChypCompletionHandler)handler { diff --git a/blockchyp-ios/Tests/MerchantInvoiceDetailTest.m b/blockchyp-ios/Tests/MerchantInvoiceDetailTest.m new file mode 100644 index 0000000..9d2c971 --- /dev/null +++ b/blockchyp-ios/Tests/MerchantInvoiceDetailTest.m @@ -0,0 +1,66 @@ +// Copyright 2019-2022 BlockChyp, Inc. All rights reserved. Use of this code +// is governed by a license that can be found in the LICENSE file. +// +// This file was generated automatically by the BlockChyp SDK Generator. +// Changes to this file will be lost every time the code is regenerated. + +#import "BlockChypTest.h" + +@interface MerchantInvoiceDetailTest : BlockChypTest + + + +@end + +@implementation MerchantInvoiceDetailTest + +- (void)setUp { + + TestConfiguration *config = [self loadConfiguration]; + BlockChyp *client = [[BlockChyp alloc] initWithApiKey:config.apiKey bearerToken:config.bearerToken signingKey:config.signingKey]; + client.gatewayHost = config.gatewayHost; + client.testGatewayHost = config.testGatewayHost; + client.dashboardHost = config.dashboardHost; + + + +} + +- (void)tearDown { + +} + +- (void)testMerchantInvoiceDetail{ + + TestConfiguration *config = [self loadConfiguration]; + BlockChyp *client = [[BlockChyp alloc] initWithApiKey:config.apiKey bearerToken:config.bearerToken signingKey:config.signingKey]; + client.gatewayHost = config.gatewayHost; + client.testGatewayHost = config.testGatewayHost; + client.dashboardHost = config.dashboardHost; + + + XCTestExpectation *expectation = [self expectationWithDescription:@"MerchantInvoiceDetail Test"]; + + NSMutableDictionary *request = [[NSMutableDictionary alloc] init]; + request[@"test"] = @YES; + + [client merchantInvoiceDetailWithRequest:request handler:^(NSDictionary *request, NSDictionary *response, NSError *error) { + + [self logJSON:response]; + XCTAssertNotNil(response); + // response assertions + XCTAssertTrue([[response objectForKey:@"success"]boolValue]); + + [expectation fulfill]; + }]; + + @try { + [self waitForExpectationsWithTimeout:60 handler:nil]; + } + @catch (NSException *exception) { + NSLog(@"Exception:%@",exception); + } + +} + +@end