Skip to content
This repository was archived by the owner on Sep 17, 2022. It is now read-only.

Conversation

@alanpjohn
Copy link
Member

closes #3

ARgorithmAPI

forthebadge

ARgorithmAPI has been created with the following functions:

  • connect : connects to end point
  • login : log in to user account
  • create : create user account
  • verify : checks for pre-existing login credentials
  • list : gets list of argorithm from server

Usage

get the imports

using ARgorithmAPI;
using ARgorithmAPI.Models;

connect

    public void connect(){
        StartCoroutine(
            APIClient.Instance.connect(
                "https://argorithm.el.r.appspot.com",
                (r) => callback(r)
            )
        );
    }

    void callback(ConnectionResponse c){
        Debug.Log(c.status);    
    }

The ConnectionResponse.status can have following values

  • FAILURE: Error has occured
  • AUTH: Connection has been estabilished and Authentication is required
  • SUCCESS: Connection has been estabilished and Authentication is not required

create

    public void createAccount(){
        StartCoroutine(
            APIClient.Instance.create(
                new Account {
                    email="sample@email.com",
                    password="NotARealPassword"
                },
                (r) => callback(r)
            )
        );
    }

    void callback(CreationResponse c){
        Debug.Log(c.status);
    }

The CreationResponse.status can have following values

  • FAILURE: Error has occured
  • SUCCESS: User account has been created
  • EXISTING: Email is already registered
  • NOT_ALLOWED: Authentication feature at endpoint is disabled, skip login

login

    public void login(){
        StartCoroutine(
            APIClient.Instance.login(
                new Account {
                    email="sample@email.com",
                    password="NotARealPassword"
                },
                (r) => callback(r)
            )
        );
    }

    void callback(LoginResponse c){
        Debug.Log(c.status);
    }

The LoginResponse.status can have following values

  • FAILURE: Error has occured
  • SUCCESS: Login successful
  • NOT_ALLOWED: Authentication feature at endpoint is disabled, skip login
  • NOT_FOUND: Email is not registered
  • INCORRECT_PASSWORD: Password is incorrect

verify

    void verify(){
        StartCoroutine(
            APIClient.Instance.verify(
                (r) => callback(r)
            )
        );
    }
    
    void callback(LoginResponse c){
        Debug.Log(c.status);
    }

The LoginResponse.status can have following values

  • FAILURE: Error has occured
  • SUCCESS: Login successful
  • RESET: Will have to login again

list

    void list(){
        StartCoroutine(
            APIClient.Instance.list(
                (r) => callback(r)
            )
        );
    }

    void callback(ARgorithmCollection lar){
        foreach (ARgorithm item in lar.items)
        {
            Debug.Log(item.argorithmID);
        }
    }

Check out the models in ARgorithmAPI/Models/Models.cs

The run problem

So I was implementing run and it is tad more complicated due to parameters and my amatuer C# skills and also with that issue still at large. But the other functions work and @Vin-dictive can start his work on #4 . We can brainstorm and add the run later

Added Readme

Simple README.md added

Singleton class and models for requests and responses made
Models are now serializable and APIclient has create account method implemented. Renamed APIclient to ARgorithmAPI
@alanpjohn
Copy link
Member Author

alanpjohn commented Feb 2, 2021

also dont worry, I removed Codacy after i saw it was linked to this repo as well
Should not affect future pull requests or commits, and it is now stuck at in progress because of that

FYI: The grade was A

@alanpjohn
Copy link
Member Author

alanpjohn commented Feb 2, 2021

Closes #4

@Vin-dictive is making his UI updates in this pull request as well so we'll review and merge that here as well

Added Login Page UI and setup scripts.
@alanpjohn
Copy link
Member Author

Going to refactor and change the JSON parser we use from the inbuilt JSON utility to JSON.net as it is much more friendly to dynamic objects and can parse JSON objects using key-value.

@yatharthmathur
Copy link
Member

You'll have to make sure the build for Android is supported with it

@alanpjohn
Copy link
Member Author

Officially Supported Platforms: We officially support all Unity platforms ..

what they say, i have added the link in the previous message, you can double check if you want

@alanpjohn
Copy link
Member Author

Migrated to JSON.net

Added run functionality

The following models have been added to support run

  • ExecutionRequest
  • ExecutionResponse
  • State

If you see the design of State, you'll notice that state_def is of type JObject. You can use the GetValue(string key) command to extract values out it like you would do in a dictionary. It is at the time of this commit, the best way to handle the dynamic structure of stateset. JObject has also been utilised in ARgorithm model.

The APIClient.run method uses a ExecutionRequest in which you have to define argorithmID and parameters. You can pass a empty JObject instance to run the default parameters. Once the form for taking user input is ready, we can pass a JObject that has the input defined and pass that into run

StartCoroutine(
    APIClient.Instance.run(
        new ExecutionRequest{
            argorithmID="bubblesort",
            parameters=new JObject()
        },
        (r) => callback(r)
    )
);

Will add code comments for documentations later, forgot about that

@Vin-dictive Vin-dictive merged commit 8d04c50 into master Feb 9, 2021
@alanpjohn alanpjohn deleted the api-client branch February 9, 2021 11:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API calls

4 participants