ProductViewController.h 3.74 KB
Newer Older
1
//
2
//  ProductViewController.h
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
//  Mobile Buy SDK
//
//  Created by Shopify.
//  Copyright (c) 2015 Shopify Inc. All rights reserved.
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//

27 28
@import UIKit;
@import Buy;
29

30 31 32 33
#import "Theme.h"
#import "PaymentViewController.h"

@interface ProductViewController : PaymentViewController
34 35 36 37 38 39 40 41

/**
 *  Creates a BUYProductViewController with a BUYClient and a theme
 *  Note: Use this initializer to instatiate a BUYProdctViewController
 *  with a custom theme. If you don't need to customize the theme
 *  use `initWithClient:`
 *
 *  @param client A BUYClient configured to your shop
42 43 44 45 46 47 48 49 50 51 52
 *  @param theme  A Theme
 *
 *  @return		  A PaymentViewController
 */
- (instancetype)initWithClient:(BUYClient *)client theme:(Theme *)theme;

/**
 *  Creates a BUYProductViewController with a BUYClient and a cart
 *
 *  @param client A BUYClient configured to your shop
 *  @param cart   A cart that enables a "Add to cart" button instead of the web checout button
53
 *
54
 *  @return		  A PaymentViewController with an "Add to cart" button
55
 */
56
- (instancetype)initWithClient:(BUYClient *)client cart:(BUYCart *)cart;
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

/**
 *  Loads the product details
 *
 *  @param productId  the product ID for the item to display
 *  @param completion a block to be called on completion of the loading of the product details. Will be called on the main thread.
 *  Upon success, the view controller should be presented modally
 */
- (void)loadProduct:(NSString *)productId completion:(void (^)(BOOL success, NSError *error))completion;

/**
 *  Alternative method when setting the product (and optionally, shop) directly on the view controller
 *
 *  @param product  the product to display
 *  @param completion block called when view controller is ready for display. Called on main thread
 */
- (void)loadWithProduct:(BUYProduct *)product completion:(void (^)(BOOL success, NSError *error))completion;

/**
 *  The loaded product ID
 */
@property (nonatomic, strong, readonly) NSString *productId;

/**
 *  The product to be displayed.  This can be set before presentation instead of calling loadProduct:completion:
 */
@property (nonatomic, strong, readonly) BUYProduct *product;

/**
 *  Returns YES when the view controller is loading data.  loadProduct: or loadWithProduct: should not be called when data is already loading
 */
@property (nonatomic, assign, readonly) BOOL isLoading;

/**
 *  This is a convenience method as an alternative to presentViewController: which will force portrait orientation.  This method is only 
 *  required when presenting from a landscape view controller.
 *
 *  @param controller The view controller where the BUYProductViewController is to be presented on
 */
- (void)presentPortraitInViewController:(UIViewController *)controller;

@end