Coder Social home page Coder Social logo

lob-ios's Introduction

Lob.com iOS Client

Lob.com iOS Client is a simple wrapper for the Lob.com API (docs).

Setting Up The Project

To include the iOS Client just put the iOS Client project within the project you want to use it in. The process is outlined on Stack Overflow: http://stackoverflow.com/questions/9370518/xcode-4-2-how-include-one-project-into-another-one

Basics

After including the iOS Client Project, import the Lob Library in the class where you want to use the iOS Client.

#import "LobLibrary.h"

Models

The lob models are all in the Models folder of the iOS Client. All models are created from a dictionary.

-(LobAddressModel*)createDemoAddress {
  NSDictionary *dict = @{@"name" : @"Harry Zhang", @"email" : @"[email protected]",
                         @"phone" : @"5555555555", @"address_line1" : @"123 Test Street",
                         @"address_line2" : @"Unit 199", @"address_city" : @"Mountain View",
                         @"address_state" : @"CA", @"address_zip" : @"94085", @"address_country" : @"US"};
    
    LobAddressModel *addrModel = [LobAddressModel initWithDictionary:dict];
    return addrModel;
}

The following models are currently supported with the iOS Client.

  LobAddressModel, LobBankAccountModel, LobCheckModel, LobCountryModel
  LobJobModel, LobObjectModel, LobPackagingModel, LobPostcardModel
  LobServiceModel, LobSettingModel, LobStateModel, LobVerifyModel

Requests

Lob requests are all found in the Requests folder of the iOS client. All requests follow a consistent naming scheme and block based return format. Lob requests should be instantiated with the api key. On list requests, the count and offset can be set as properties on the request object.

-(void)listAddresses {
  request = [[LobRequest alloc] initWithAPIKey:@""];
  [request listAddressesWithResponse:^(NSArray *addresses, NSError *error) {
        NSLog(@"*** Address List Response ***");
        NSLog(@"HTTP Status Code: %i", request.statusCode);
        NSLog(@"    Addresses: %@",addresses);
    }];
}

The following requests are currently supported with the iOS Client.

/**
 * Address Requests
 */

-(void)listAddressesWithResponse:(void(^) (NSArray *addresses, NSError *error))response;

-(void)createAddressWithModel:(LobAddressModel*)address withResponse:(void(^) (LobAddressModel *addr, NSError *error))response;

-(void)retrieveAddressWithId:(NSString*)addrId withResponse:(void(^) (LobAddressModel *addr, NSError *error))response;

-(void)deleteAddressWithId:(NSString*)addrId withResponse:(void(^) (NSString *message, NSError *error))response;

/**
 * Bank Account Requests
 */

-(void)listBankAccountsWithResponse:(void(^) (NSArray *accounts, NSError *error))response;

-(void)createBankAccountWithModel:(LobBankAccountModel*)bankAccount withResponse:(void(^) (LobBankAccountModel *bankAccount, NSError *error))response;

-(void)retrieveBankAccountWithId:(NSString*)bankId withResponse:(void(^) (LobBankAccountModel *bankAccount, NSError *error))response;

/**
 * Check Requests
 */

-(void)listChecksWithResponse:(void(^) (NSArray *checks, NSError *error))response;

-(void)createCheckWithModel:(LobCheckModel*)check withResponse:(void(^) (LobCheckModel *check, NSError *error))response;

-(void)retrieveCheckWithId:(NSString*)checkId withResponse:(void(^) (LobCheckModel *check, NSError *error))response;

/**
 * Country Requests
 */

-(void)listCountriesWithResponse:(void(^) (NSArray *countries, NSError *error))response;

/**
 * Job Requests
 */

-(void)listJobsWithResponse:(void(^) (NSArray *jobs, NSError *error))response;

-(void)createJobWithModel:(LobJobModel*)job withResponse:(void(^) (LobJobModel *job, NSError *error))response;

-(void)retrieveJobWithId:(NSString*)jobId withResponse:(void(^) (LobJobModel *job, NSError *error))response;

/**
 * Object Requests
 */

-(void)listObjectsWithResponse:(void(^) (NSArray *objects, NSError *error))response;

-(void)createObjectWithModel:(LobObjectModel*)object withResponse:(void(^) (LobObjectModel *object, NSError *error))response;

-(void)retrieveObjectWithId:(NSString*)objectId withResponse:(void(^) (LobObjectModel *object, NSError *error))response;

-(void)deleteObjectWithId:(NSString*)objectId withResponse:(void(^) (NSString *message, NSError *error))response;

/**
 * Packaging Requests
 */

-(void)listPackagingsWithResponse:(void(^) (NSArray *packagings, NSError *error))response;

/**
 * Postcard Requests
 */

-(void)listPostcardsWithResponse:(void(^) (NSArray *postcards, NSError *error))response;

-(void)createPostcardWithModel:(LobPostcardModel*)postcard withResponse:(void(^) (LobPostcardModel *postcard, NSError *error))response;

-(void)retrievePostcardWithId:(NSString*)postcardId withResponse:(void(^) (LobPostcardModel *postcard, NSError *error))response;

/**
 * Service Requests
 */

-(void)listServicesWithResponse:(void(^) (NSArray *services, NSError *error))response;

/**
 * Setting Requests
 */

-(void)listSettingsWithResponse:(void(^) (NSArray *settings, NSError *error))response;

-(void)retrieveSettingWithId:(NSString*)settingId withResponse:(void(^) (LobSettingModel *setting, NSError *error))response;

/**
 * State Requests
 */

-(void)listStatesWithResponse:(void(^) (NSArray *states, NSError *error))response;

/**
 * Verify Requests
 */

-(void)verifyAddressModel:(LobAddressModel*)addr withResponse:(void(^) (LobVerifyModel *validation, NSError *error))response;

Tests

To run the iOS Client tests open up the iOS Client project, then build and test. Tests are located in the lob-iosTests folder.

lob-ios's People

Contributors

msencenb avatar zamoeba avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.