Git Product home page Git Product logo

otohits-api-csharp's Introduction

Otohits API - C#

C# implementation of the Otohits API (http://docs.otohitsapi.apiary.io).

Quick start

You can use the Otohits.API.TestConsole project to play with the API.

Add your API Key/Secret in the App.Config file:

<appSettings>
  <add key="Otohits:API:Key" value="yourApiKey"/>
  <add key="Otohits:API:Secret" value="yourSecret"/>
</appSettings>

Launch the Console App and... That's it! You should get your account info.

How to use

Set your credentials once to make all further requests

OtohitsRequest.SetCredentials("yourApiKey", "yourSecret");

Make a request

Using a mapped method

var user = new OtohitsRequest().GetUserInfo();

Using a custom call

Most of the services are directly mapped into OtohitsRequest, but if you need to make a specific request, you can use Get, Post, Put and Delete methods.

Both can retrieve either a JSON string or a POCO object (JSON deserialize).

Basic Get, Post, Put and Delete methods also have Async() methods.

You can use the POCO object if available

 var user = new OtohitsRequest().Get<ApiResponse<User>>("/me");

Or just get back the JSON string if needed:

string userResponse = new OtohitsRequest().Get("/me");

APIResponse

All the response coming from the API return an object with the status (success), the data (data...) and errors if any.

public class ApiResponse
{
    public bool IsSuccess { get; set; }
    public List<ApiError> Errors { get; set; }
}

public class ApiResponse<T>
{
    public bool IsSuccess { get; set; }
    public T Data { get; set; }
    public List<ApiError> Errors { get; set; }
}

KISS :)

otohits-api-csharp's People

Contributors

pfvc298 avatar

Watchers

James Cloos avatar

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.