Commit 6c758e68 by David Muzi

Add customer update endpoint

remove customer update unit test
parent edcaa8e9
...@@ -197,29 +197,6 @@ ...@@ -197,29 +197,6 @@
[self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {}]; [self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {}];
} }
#pragma mark - Update -
- (void)testCustomerUpdate
{
[OHHTTPStubs stubUsingResponseWithKey:@"testCustomerLogin" useMocks:[self shouldUseMocks]];
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
BUYAccountCredentialItem *email = [BUYAccountCredentialItem itemWithEmail:self.customerEmail];
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:@[email]];
[self.client updateCustomerWithCredentials:credentials callback:^(BUYCustomer *customer, NSError *error) {
XCTAssertNil(error);
XCTAssertNotNil(customer);
XCTAssertEqualObjects(customer.email, self.customerEmail);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
}
#pragma mark - Address - #pragma mark - Address -
- (void)testGetAddresses - (void)testGetAddresses
......
...@@ -119,14 +119,13 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -119,14 +119,13 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
/** /**
* PUT /api/customers/:customer_id * PUT /api/customers/:customer_id
* Update customer credentials represented by BUYAccountCredentials object
* *
* @param credentials Credentials containing a password * @param customer the customer object to update
* @param block (BUYCustomer *customer, NSError *error) * @param block (BUYCustomer *customer, NSError *error)
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (NSOperation *)updateCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerBlock)block; - (NSOperation *)updateCustomer:(BUYCustomer *)customer callback:(BUYDataCustomerBlock)block;
/** /**
* PUT /api/customers/:customer_id/reset * PUT /api/customers/:customer_id/reset
......
...@@ -82,10 +82,10 @@ ...@@ -82,10 +82,10 @@
}]; }];
} }
- (NSOperation *)updateCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerBlock)block - (NSOperation *)updateCustomer:(BUYCustomer *)customer callback:(BUYDataCustomerBlock)block
{ {
NSURL *url = [self urlForLoggedInCustomer]; NSURL *url = [self urlForCustomersWithID:customer.identifier.stringValue];
return [self putRequestForURL:url object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self putRequestForURL:url object:@{@"customer": customer.JSONDictionary} completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
BUYCustomer *customer = nil; BUYCustomer *customer = nil;
if (json && !error) { if (json && !error) {
customer = [self.modelManager customerWithJSONDictionary:json]; customer = [self.modelManager customerWithJSONDictionary:json];
......
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