CalStorePageItemParameterizedCalendar Class Reference

Inherits from CalStorePageItemCalendar : CalStorePageItemPurchasable : CalStorePageItem : CalStoreObject : NSObject
Declared in CalStorePageItemParameterizedCalendar.h

Overview

A parameterized calendar cannot immediately create an url, but first needs a set of values for its parameters. For example, the weather calendar needs to have a location parameter to be able to create a full url.

The createUrlWithCompletionHandler: method will fail, until values for all parameters have been supplied.

Parameters

The set of all parameters that need to be supplied can be fetched using the parameters property. E.g. 'rain', 'wind', 'location', 'language'.

Values

Set properties using the allParametersValues dictionary property or the setValue:forParameter: message. E.g. [item setValue:@"en_US" forParameter:@"language"].

Options

Some parameters have a fixed list of options the user can pick from; use the parametersOptions property to get a dictionary of parameters to CalStoreParameterOptions objects, which hold information about the title and various options possible for that particular parameter. E.g. 'wind' => {title: 'Vent', options: ['kmh' => 'Kilometre/heure', 'mph' => 'Miles/heure']}.

If parametersOptions is nil, use fetchParameterOptionsWithCompletionHandler: to fetch them asynchronously from the API server.

URL

To be able to create a full URL for a ParameterizedCalendar, make sure you have supplied values for all parameters:

  • parameters without options need to be supplied by the app (e.g. language, location)
  • parameters with options can be picked by the user with appropriate UI

Parameters

  parameters

A set of the names of all parameters that MUST be supplied to be able to be able to create a full url.

@property (nonatomic, readonly) NSSet *parameters

Discussion

These names should be the keys of the allParametersValues dictionary.

Declared In

CalStorePageItemParameterizedCalendar.h

Setting Parameter Values

  allParametersValues

Set with an NSDictionary with all values for all parameters. The keys of the parameters should be all the names in the parameters property, the values should be NSString objects.

@property (nonatomic, copy) NSDictionary *allParametersValues

Declared In

CalStorePageItemParameterizedCalendar.h

– setValue:forParameter:

Sets a single parameter in the allParametersValues dictionary. Overrides any existing values for the given key. If value is nil, the key will be removed from the allParametersValues dictionary.

- (void)setValue:(id)value forParameter:(NSString *)key

Parameters

value

the value to set for the parameter

key

the name of the parameter to set

Declared In

CalStorePageItemParameterizedCalendar.h

  hasValuesForAllParameters

YES if all parameters have values in the allParametersValues dictionary.

@property (nonatomic, readonly) BOOL hasValuesForAllParameters

Discussion

Iff YES, it is possible to create a full url with createUrlWithCompletionHandler:

Declared In

CalStorePageItemParameterizedCalendar.h

Parameters Options

  parametersOptions

An NSDictionary describing the possible values for parameters that have selectable options. The keys of the dictionary are the names from the parameters property that have options. The values in this dictionary are of type CalStoreCalendarParameterOptions. If nil, use fetchParameterOptionsWithCompletionHandler:.

@property (nonatomic, readonly) NSDictionary *parametersOptions

Discussion

The options are requested from the API, so they are not readibly available. If this property is nil, call fetchParameterOptionsWithCompletionHandler: to fetch the options from the API.

Declared In

CalStorePageItemParameterizedCalendar.h

Fetching Parameters Options

– fetchParametersOptionsWithCompletionHandler:

Call when parametersOptions is nil. Will asynchronously fetch the parametersOptions from the API.

- (void)fetchParametersOptionsWithCompletionHandler:(CalStoreParametersOptionsCompletionHandler)completionHandler

Parameters

completionHandler

When the fetch operation finishes, the completionHandler will be invoked on the main queue.

Discussion

Note: Calling this method when fetchingParametersOptions is YES will raise an exception.

This method will use the authorizationToken from the CalStoreController. If you want to provide the authorizationToken yourself, use fetchParametersOptionsWithCompletionHandler:authorizationToken:

Declared In

CalStorePageItemParameterizedCalendar.h

– fetchParametersOptionsWithCompletionHandler:authorizationToken:

Same as fetchParametersOptionsWithCompletionHandler:, but with the option of using a custom authorizationToken.

- (void)fetchParametersOptionsWithCompletionHandler:(CalStoreParametersOptionsCompletionHandler)completionHandler authorizationToken:(NSString *)authorizationToken

Parameters

completionHandler

When the fetch operation finishes, the completionHandler will be invoked on the main queue.

authorizationToken

the AuthorizationToken to use for the underlying API request that’s being made

Discussion

Note: Only use if you need to provide a different token than the one used by CalStoreController.

Declared In

CalStorePageItemParameterizedCalendar.h

– cancelParametersOptionsFetch

Cancels an ongoing parametersOptions fetch request.

- (void)cancelParametersOptionsFetch

Declared In

CalStorePageItemParameterizedCalendar.h

  fetchingParametersOptions

YES if this object is busy fetching parametersOptions.

@property (nonatomic, readonly, getter=isFetchingParametersOptions) BOOL fetchingParametersOptions

Declared In

CalStorePageItemParameterizedCalendar.h

  parametersOptionsUrl

the URL where a JSON object can be found, describing possible values for the parameters. Normally, one uses the parameterOptions property.

@property (nonatomic, readonly) NSURL *parametersOptionsUrl

Discussion

Note: It’s recommended to use fetchParametersOptionsWithCompletionHandler:.

Declared In

CalStorePageItemParameterizedCalendar.h