Clean up "set default subscription payment method" request.
This commit is contained in:
parent
0e59a3040a
commit
ea970bbd02
@ -455,8 +455,8 @@ public class SubscriptionManagerImpl: NSObject {
|
||||
using processor: PaymentProcessor,
|
||||
paymentID: String
|
||||
) -> Promise<Void> {
|
||||
let request = OWSRequestFactory.subscriptionSetDefaultPaymentMethodRequest(
|
||||
subscriberID.asBase64Url,
|
||||
let request = OWSRequestFactory.subscriptionSetDefaultPaymentMethod(
|
||||
subscriberID: subscriberID,
|
||||
processor: processor.rawValue,
|
||||
paymentID: paymentID
|
||||
)
|
||||
|
||||
@ -174,9 +174,6 @@ typedef NS_ENUM(uint8_t, OWSIdentity);
|
||||
returnUrl:(NSURL *)returnUrl
|
||||
cancelUrl:(NSURL *)cancelUrl
|
||||
NS_SWIFT_NAME(subscriptionCreatePaypalPaymentMethodRequest(subscriberId:returnUrl:cancelUrl:));
|
||||
+ (TSRequest *)subscriptionSetDefaultPaymentMethodRequest:(NSString *)base64SubscriberID
|
||||
processor:(NSString *)processor
|
||||
paymentID:(NSString *)paymentID;
|
||||
+ (TSRequest *)subscriptionSetSubscriptionLevelRequest:(NSString *)base64SubscriberID level:(NSString *)level currency:(NSString *)currency idempotencyKey:(NSString *)idempotencyKey;
|
||||
+ (TSRequest *)subscriptionReceiptCredentialsRequest:(NSString *)base64SubscriberID
|
||||
request:(NSString *)base64ReceiptCredentialRequest;
|
||||
|
||||
@ -643,23 +643,6 @@ NSString *const OWSRequestKey_AuthKey = @"AuthKey";
|
||||
return request;
|
||||
}
|
||||
|
||||
+ (TSRequest *)subscriptionSetDefaultPaymentMethodRequest:(NSString *)base64SubscriberID
|
||||
processor:(NSString *)processor
|
||||
paymentID:(NSString *)paymentID
|
||||
{
|
||||
TSRequest *request = [TSRequest
|
||||
requestWithUrl:[NSURL
|
||||
URLWithString:[NSString stringWithFormat:@"/v1/subscription/%@/default_payment_method/%@/%@",
|
||||
base64SubscriberID,
|
||||
processor,
|
||||
paymentID]]
|
||||
method:@"POST"
|
||||
parameters:@{}];
|
||||
request.shouldHaveAuthorizationHeaders = NO;
|
||||
request.shouldRedactUrlInLogs = YES;
|
||||
return request;
|
||||
}
|
||||
|
||||
+ (TSRequest *)subscriptionSetSubscriptionLevelRequest:(NSString *)base64SubscriberID level:(NSString *)level currency:(NSString *)currency idempotencyKey:(NSString *)idempotencyKey {
|
||||
TSRequest *request = [TSRequest requestWithUrl:[NSURL URLWithString:[NSString stringWithFormat:@"/v1/subscription/%@/level/%@/%@/%@", base64SubscriberID, level, currency, idempotencyKey]]
|
||||
method:@"PUT"
|
||||
|
||||
@ -176,6 +176,28 @@ public extension OWSRequestFactory {
|
||||
result.shouldRedactUrlInLogs = true
|
||||
return result
|
||||
}
|
||||
|
||||
static func subscriptionSetDefaultPaymentMethod(
|
||||
subscriberID: Data,
|
||||
processor: String,
|
||||
paymentID: String
|
||||
) -> TSRequest {
|
||||
let result = TSRequest(
|
||||
url: .init(pathComponents: [
|
||||
"v1",
|
||||
"subscription",
|
||||
subscriberID.asBase64Url,
|
||||
"default_payment_method",
|
||||
processor,
|
||||
paymentID
|
||||
])!,
|
||||
method: "POST",
|
||||
parameters: nil
|
||||
)
|
||||
result.shouldHaveAuthorizationHeaders = false
|
||||
result.shouldRedactUrlInLogs = true
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Messages
|
||||
|
||||
@ -182,6 +182,19 @@ class OWSRequestFactoryTest: XCTestCase {
|
||||
XCTAssertTrue(request.shouldRedactUrlInLogs)
|
||||
}
|
||||
|
||||
func testSubscriptionSetDefaultPaymentMethod() {
|
||||
let request = OWSRequestFactory.subscriptionSetDefaultPaymentMethod(
|
||||
subscriberID: Data([255, 128]),
|
||||
processor: "STRIPE",
|
||||
paymentID: "xyz"
|
||||
)
|
||||
|
||||
XCTAssertEqual(request.url?.path, "v1/subscription/_4A/default_payment_method/STRIPE/xyz")
|
||||
XCTAssertEqual(request.httpMethod, "POST")
|
||||
XCTAssertFalse(request.shouldHaveAuthorizationHeaders)
|
||||
XCTAssertTrue(request.shouldRedactUrlInLogs)
|
||||
}
|
||||
|
||||
// MARK: - Spam
|
||||
|
||||
func testReportSpamFromUuid() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user