Inherits from NSObject
Conforms to ASIHTTPRequestDelegate
Declared in MBQuery.h
MBQuery.m

Overview

Main interface with the webservice.

MBQuery handles all communication to and from the webservice. Use MBRequest to form the request. Use MBQueryDelegate to receive callbacks on success or failure. If the request fails due to network connectivity, MBQuery will not resend the request.

Tasks

Other Methods

Other Methods

Properties

Delegate

MBQueryDelegate that recieves callbaks for recieved data

@property (cpt_weak_property, nonatomic) id<MBQueryDelegate> Delegate

Discussion

MBQueryDelegate that recieves callbaks for recieved data

Declared In

MBQuery.h

Port

Port to use when connecting.

@property (assign, nonatomic) int Port

Discussion

Port to use when connecting.

Default is 80

Declared In

MBQuery.h

Server

Server to connect to.

@property (copy, nonatomic) NSString *Server

Discussion

Server to connect to.

Default is musicbrainz.org

Declared In

MBQuery.h

UserAgent

User Agent string.

@property (copy, nonatomic) NSString *UserAgent

Discussion

User Agent string.

Client name to report to the webservice for mutable requests. The recommended format is “application-version”, where version does not contain a – character.

Warning: ua must not be empty or nil.

Declared In

MBQuery.h

Class Methods

addQueryStringToUrl:params:

+ (NSString *)addQueryStringToUrl:(NSString *)url params:(NSDictionary *)params

initialize

+ (void)initialize

Instance Methods

delete:parameters:

- (void)delete:(NSString *)endpoint parameters:(NSDictionary *)parameters

didFailWithError:

- (void)didFailWithError:(NSError *)error

didFinishWithMetadata:

- (void)didFinishWithMetadata:(MBMetadata *)metadata

get:parameters:

- (void)get:(NSString *)endpoint parameters:(NSDictionary *)parameters

init

- (id)init

initWithUserAgent:Delegate:

Initializes with default server and port

- (id)initWithUserAgent:(NSString *)ua Delegate:(id<MBQueryDelegate>)delegate

Parameters

ua

User Agent string to report to the webservice for mutable requests. The recommended format is “application-version”, where version does not contain a – character. @warning ua must not be empty or nil.

delegate

MBQueryDelegate that recieves callbacks for recieved data

Discussion

Initializes with default server and port

MBQuery must be initialized with a user agent string. If the string is empty nil is returned. delegate must also not be nil. Default server:Port is musicbrainz.org:80

Declared In

MBQuery.h

initWithUserAgent:Delegate:Server:Port:

Main initializer.

- (id)initWithUserAgent:(NSString *)ua Delegate:(id<MBQueryDelegate>)delegate Server:(NSString *)server Port:(int)port

Parameters

ua

User Agent string to report to the webservice for mutable requests. The recommended format is “application-version”, where version does not contain a – character. ua must not be empty or nil.

delegate

MBQueryDelegate that recieves callbacks for recieved data

server

Server to connect to.

port

Port to use.

Discussion

Main initializer.

MBQuery must be initialized with a user agent string. If the string is empty nil is returned. delegate must also not be nil.

Declared In

MBQuery.h

post:parameters:data:

- (void)post:(NSString *)endpoint parameters:(NSDictionary *)parameters data:(NSData *)data

put:parameters:data:

- (void)put:(NSString *)endpoint parameters:(NSDictionary *)parameters data:(NSData *)data

queryWithEntity:uid:resource:parameters:

Query the webservice. Will call [MBQueryDelegate query:didReceiveResult:] on success else else [MBQueryDelegate query:didFailWithError:] on failure

- (void)queryWithEntity:(NSString *)entity uid:(NSString *)idstr resource:(NSString *)resource parameters:(NSDictionary *)parameters

Parameters

entity

type of entity to lookup (artist, release, etc)

idstr

MBID for the entity

resource

Currently only used for Collections

parameters

paramters to use (e.g. inc). If parameters contains the key “inc”, the value must be a type of NSArray

Discussion

Query the webservice. Will call [MBQueryDelegate query:didReceiveResult:] on success else else [MBQueryDelegate query:didFailWithError:] on failure

Declared In

MBQuery.h

requestFailed:

- (void)requestFailed:(ASIHTTPRequest *)request

requestFinished:

- (void)requestFinished:(ASIHTTPRequest *)request

setUsername:Password:

Set the username and password to authenticate with when making mutable requests or getting user specific information, like collections, user-ratings, and user-tags

- (void)setUsername:(NSString *)username Password:(NSString *)password

Parameters

username

username to authenticate with

password

password to authenticate with

Discussion

Set the username and password to authenticate with when making mutable requests or getting user specific information, like collections, user-ratings, and user-tags

The library assumes no persistence for this data, username and password will persist until at least the end of life of this object.

Declared In

MBQuery.h

submitQueue

Submits all queued posts or puts.

- (void)submitQueue

Discussion

Submits all queued posts or puts.

Must call setUsername:Password: before calling or else requests will fail

Declared In

MBQuery.h

urlWithEndpoint:parameters:

- (NSURL *)urlWithEndpoint:(NSString *)endpoint parameters:(NSDictionary *)params