Giter Site home page Giter Site logo

ideaegg-api's People

Contributors

andrecrt avatar bootstraponline avatar capablemonkey avatar chrissrogers avatar cvkef avatar davidstanley01 avatar dmyers avatar fermayo avatar floorlamp avatar germanattanasio avatar hw676018683 avatar intelliot avatar joelr avatar kevin-buttercoin avatar kpavlov avatar lord avatar mattes avatar mdlima avatar moizjv avatar niksamokhvalov avatar realityking avatar rlord avatar sobstel avatar stetzer avatar styloa avatar swarzech avatar xmo-odoo avatar xunzhang avatar zdenekdrahos avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

wymen fanxy1

ideaegg-api's Issues

v1和v2差别

v1和v2的差别

api v1 v2
点赞 POST /ideas/:id/like PATCH/PUT /ideas/:id/vote
取消点赞 DELETE /ideas/:id/like DELETE /ideas/:id/vote
用户信息更新 PUT /users/:id PATCH/PUT /user
收藏 POST /ideas/:id/star PUT /ideas/:id/star
我发布的 idea GET /my/ideas GET /user/ideas/created
用户自己点赞的 idea GET /my/liked_ideas GET /user/ideas/voted
用户自己收藏的 idea GET /my/starred_ideas GET /user/ideas/starred
给 idea 打标签 PUT /ideas/:id/tag POST /ideas/:id/tags
取消 idea 的标签 PUT /ideas/:id/untag DELETE /ideas/:id/tags

Interface called by iOS

We call interface using AFNetworking 2.x, prefer to use JSON parameters.

       path = [NSString stringWithFormat:@"%@?page=%@", path, _nextPage];    This line of code show the way to make commad is not good.
       //[parameters setObject:@"ideaegg" forKey:@"username"];  This is good since parameter in JSON.
        [manager.requestSerializer setValue:appDelegate.userKey forHTTPHeaderField:@"PRIVATE-TOKEN"];     Private TOKEN in the HttpHeader.

Sample code for load ideas:

- (void) onLoadMyIdeaList:(BOOL)isFirst{

    NSString *baseURL = BASEURL;
    NSString *path;
    if(_loadType == 1){
      path = [NSString stringWithFormat:@"%@/api/v1/my/ideas", baseURL];
    }
    if(_loadType == 2){
        path = [NSString stringWithFormat:@"%@/api/v1/my/liked_ideas", baseURL];
    }
    if(_loadType == 3){
        path = [NSString stringWithFormat:@"%@/api/v1/my/starred_ideas", baseURL];
    }

    if (!isFirst && ([_nextPage longValue] != 0)) {
        path = [NSString stringWithFormat:@"%@?page=%@", path, _nextPage];    
        if ([self.dataSource count] >= [_totalRecords longValue]) {
            [self reloadData];
        }
    }
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    //[parameters setObject:@"ideaegg" forKey:@"username"];

    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    [manager.requestSerializer setValue:appDelegate.userKey forHTTPHeaderField:@"PRIVATE-TOKEN"];

    [manager GET:path parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        //NSLog(@"JSON: %@", responseObject);
        if ([responseObject isKindOfClass:[NSArray class]]) {
            NSArray *responseArray = responseObject;

            NSLog(@"Response NSArray! %ld records", (unsigned long)[responseArray count]);

            [self onReadOneIdeaPackage:responseArray];

            [self reloadData];
            /* do something with responseArray */
        } else if ([responseObject isKindOfClass:[NSDictionary class]]) {
            //NSDictionary *responseDict = responseObject;
            /* do something with responseDict */
        }

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
        [self reloadData];
    }];
}

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.