Commit a5f35086 by Brent Gulanowski

Change BUYClient.customerToken from string to BUYCustomerToken.

parent e81100f8
......@@ -119,7 +119,7 @@
return [self putRequestForURL:url object:nil completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
NSString *accessToken = nil;
if (json && !error) {
BUYCustomerToken *authenticatedResponse = [BUYCustomerToken responseWithJSON:json];
BUYCustomerToken *authenticatedResponse = [BUYCustomerToken customerTokenWithJSON:json];
accessToken = authenticatedResponse.accessToken;
}
......@@ -191,16 +191,16 @@
return [self postRequestForURL:url object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
if (json && !error) {
BUYCustomerToken *authenticatedResponse = [BUYCustomerToken customerTokenWithJSON:json];
self.customerToken = authenticatedResponse.accessToken;
self.customerToken = authenticatedResponse;
if (!customerJSON) {
[self getCustomerWithID:authenticatedResponse.customerID callback:^(BUYCustomer *customer, NSError *error) {
block(customer, self.customerToken, error);
block(customer, self.customerToken.accessToken, error);
}];
}
else {
BUYCustomer *customer = [self.modelManager customerWithJSONDictionary:customerJSON];
block(customer, self.customerToken, error);
block(customer, self.customerToken.accessToken, error);
}
}
else {
......
......@@ -25,8 +25,9 @@
//
@import Foundation;
#import "BUYClientTypes.h"
#import <Buy/BUYClientTypes.h>
@class BUYCustomerToken;
@class BUYModelManager;
@class BUYOperation;
@class BUYRequestOperation;
......@@ -97,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN
*
* @param token The token received from the create and login callbacks
*/
@property (strong, nonatomic, nullable) NSString *customerToken;
@property (strong, nonatomic, nullable) BUYCustomerToken *customerToken;
@end
......
......@@ -26,6 +26,7 @@
#import "BUYClient+Internal.h"
#import "BUYAssert.h"
#import "BUYCustomerToken.h"
#import "BUYModelManager.h"
#import "BUYRequestOperation.h"
......@@ -222,7 +223,7 @@ static NSString * const BUYClientJSONMimeType = @"application/json";
[request addValue:BUYClientJSONMimeType forHTTPHeaderField:@"Accept"];
if (self.customerToken) {
[request addValue:self.customerToken forHTTPHeaderField:BUYClientCustomerAccessToken];
[request addValue:self.customerToken.accessToken forHTTPHeaderField:BUYClientCustomerAccessToken];
}
request.HTTPMethod = method;
......
......@@ -27,6 +27,7 @@
#import "BUYWebCheckoutPaymentProvider.h"
#import "BUYCheckout.h"
#import "BUYClient+Checkout.h"
#import "BUYCustomerToken.h"
#import "BUYAssert.h"
@import SafariServices;
......@@ -176,11 +177,11 @@ static NSString *const WebCheckoutCustomerAccessToken = @"customer_access_token"
- (NSURL *)authenticatedWebCheckoutURL:(NSURL *)url
{
NSString *customerToken = self.client.customerToken;
if (!customerToken.length) {
NSString *accessToken = self.client.customerToken.accessToken;
if (!accessToken.length) {
return url;
}
NSURLQueryItem *item = [NSURLQueryItem queryItemWithName:WebCheckoutCustomerAccessToken value:customerToken];
NSURLQueryItem *item = [NSURLQueryItem queryItemWithName:WebCheckoutCustomerAccessToken value:accessToken];
NSURLComponents *authenticatedComponents = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:YES];
authenticatedComponents.queryItems = authenticatedComponents.queryItems ? [authenticatedComponents.queryItems arrayByAddingObject:item] : @[item];
return authenticatedComponents.URL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment