GithubHelp home page GithubHelp logo

jleveugle / ovh-angular-http Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ovh-ux/ng-ovh-http

0.0 1.0 0.0 119 KB

Simple http provider for ovh api

License: Other

JavaScript 84.74% Makefile 15.26%

ovh-angular-http's Introduction

ovh-angular-http

githubbanner

Maintenance Chat on gitter Build Status

NPM

Simple http provider for OVH API.

Installation

Bower

$ bower install ovh-angular-http --save

NPM

$ npm install ovh-angular-http --save

Get the sources

$ git clone https://github.com/ovh-ux/ovh-angular-http.git
$ cd ovh-angular-http
$ npm install
$ bower install

Configuration

.config(["OvhHttpProvider", "constants", function (OvhHttpProvider, constants) {
    "use strict";
    OvhHttpProvider.rootPath = constants.swsRootPath; // URL prefix
    OvhHttpProvider.clearCacheVerb = ["POST", "PUT", "DELETE"]; // Auto delete get cache (for this url) if method is in table
    OvhHttpProvider.returnSuccessKey = 'data'; // By default, requeste return response.data
    OvhHttpProvider.returnErrorKey = 'data'; // By default, requeste return error.data
}])

Usage

    // http request
    OvhHttp.["get", "put", "post", "delete"](URL, options); (promise)

    // get API schema (option only rootPath)
    OvhHttp.schema(URL, options); (promise)

    // get specifically enum of API schema (option only rootPath)
    OvhHttp.models(URL, enumName, options); (promise)

    // return window.encodeURIComponent(param);
    OvhHttp.encode(param);

Options

 options = {
    method:           // get post put or delete
    url:              // url of sws or proxypass
    urlParams:        // params of url (replace {*})
    data:             // data of body for POST and PUT
    params:           // params in URL
    cache:            // cache key (String)
    clearCache:       // (String, String[], boolean) clear cache of this url (boolean) or specifique cache (String or String[])
    clearAllCache:    // (String, String[], boolean) clear all cache of this cache (boolean) or specifique cache (String or String[])
    encodeParams:     // Encode params
    encodeUrlParams:  // Encode url params

    // Override provider conf
    returnSuccessKey: // (String or empty string) return specific key (first level) (empty for return all)
    returnErrorKey:   // (String or empty string) return specific key (first level) (empty for return all)
    rootPath:         // prefix url (provider conf)
    clearCacheVerb:   // table of [PUT POST DELETE]. remove automatically cache of url if method is in table(provider conf)
 }

Example

    this.getSelected = function (forceRefresh) {
        return OvhHttp.get("hosting/web/{serviceName}", {
            urlParams: {
                serviceName: $routeParams.productId
            },
            clearCache: forceRefresh,
            cache: "hostingCache"
        });
    };

    this.flushCdn = function () {
        return OvhHttp.post("proxypass/hosting/web/{serviceName}/request", {
            urlParams: {
                serviceName: $routeParams.productId
            },
            data: {
                action: "FLUSH_CACHE"
            }
            clearAllCache: "hostingCache" // or ["hostingCache"]
        });
    };

You've developed a new cool feature? Fixed an annoying bug? We'd be happy to hear from you!

Have a look in CONTRIBUTING.md

Related links

License

See https://github.com/ovh-ux/ovh-angular-http/blob/master/LICENSE

ovh-angular-http's People

Contributors

antleblanc avatar jleveugle 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.