LogN Magento is an unofficial client library for Magento Service (SOAPv1). Supports Mac and iOS
LogN Magento works on iOS5+ and ARC. It depends on the following lib(s):
You will need LLVM 3.0 or later in order to build LogN Magento.
- Move inside your git tracked project.
- Add LogNMagento as a submodule:
git submodule add git://github.com/lognllc/LogNMagento.git
. - Open your project in Xcode, than drag and drop
Magento
folder to your classes group (in the Groups & Files view). - Don't select Copy items and select a suitable Reference type (relative to project should work fine most of the time).
- Add AFNetworking too:
git submodule add git://github.com/AFNetworking/AFNetworking.git
. - Add frameworks:
SystemConfigration
,MobileCoreServices
- Add header search path
user/include/libxml2
- Define your server
#define MAGENTO_BASE_URL @"http://yourserver/index.php/api/"
#define MAGENTO_USERNAME = @"xxx"
#define MAGENTO_API_KEY = @"xxx"
Best practice is to renew session when `-applicationDidBecomeActive:`:
- (void)applicationDidBecomeActive:(UIApplication *)application
{
Magento.service.storeID = @1;
[Magento.service renewSession];
...
}
An sample of create customer would be:
[Magento call:@[@"customer.create", @{
@"email": email,
@"password": password,
@"firstname": firstname,
@"lastname": lastname,
@"website_id": @1,
@"store_id": Magento.service.storeID
}] success:^(AFHTTPRequestOperation *operation, id responseObject) {
Magento.service.customerID = responseObject;
NSLog(@"signUp customerID = %@", Magento.service.customerID);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error %@", error.localizedDescription);
}];
LogN Magento is available under the Apache License (v2).