npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-rec-api

v1.0.0

Published

An Angular 2+ Api Interface

Downloads

3

Readme

REC Barcelona (Angular 2+ API)

A little api interface for REC Barcelona.

!! WARNING !! THIS LIBRARY IS IN BETA, USE AT YOUR OWN RISK

Table Of Content

Installing

Using npm:

npm install ng-rec-api -s

Setting Up

Setting up is as easy as any other Angular library, just import the module and add it to the AppModule imports.

// app.module.ts
import { RecApiModule, REC_APP_CONFIG } from 'ng-rec-api';

@NgModule({
    imports: [
        RecApiModule
    ],
    providers: [
        {
            provide: REC_APP_CONFIG,
            useValue: {
                url: "https://api.rec.barcelona.com",
                client_id: "...",
                client_secret: "...",
                grant_type: 'client_credentials',
            }
        },
    ]
})
export class AppModule {

}

You must also provide REC_APP_CONFIG, containing the url and client credentials

Usage

Using it is also pretty simple, just import the service and start using it.

Note:

Some calls have various versions available.

  rec.auth.token({ ... }, 'v1');
  rec.auth.tokenV1({ ... });
  rec.auth.tokenV2({ ... });
  rec.auth.tokenV3({ ... });

Example:

// app.component.ts
import { RecApiService, TokenSet } from '../packages/rec-api';

export class AppComponent {
    constructor(
        private rec: RecApiService
    ){
        rec.oauth.clientToken('v2')
            .subscribe(
                (token: TokenSet) => {
                    /**
                     * `persistToken` saves token to localStorage with a name 
                     * can be later retrieved via `restoreToken`
                     */
                    rec.auth.persistToken('app', token);

                    let appToken = rec.auth.restoreToken('app');
                }, 
                (error) => {
                    console.error(error.message);
                }
            );
    }
}

API

List of methods by version:

auth

  • loggedIn : boolean
  • persistToken: TokenSet
  • restoreToken: TokenSet

oauth

  • token(data: AuthTokenData, version: 'v1' | 'v2' | 'v3'): Observable<Response>
  • registerUser(data: RegisterUserData): Observable<Response>
  • validateUserPhone(dni: string, code: string): Observable<Response>
  • clientToken(): Observable<Response>
  • userToken(data: UserTokenData): Observable<Response>
  • getToken(): TokenSet

status

Returns status

user

  • account(): Observable<User>
  • update(data: any): Observable<any>
  • saveKyc(data: any): Observable<any>
  • exchangers(): Observable<any>
  • uploadFile(file: File): Observable<any>
  • profileImage(url): Observable<any>
  • settings(): Observable<any>
  • phoneList(): Observable<any>
  • publicPhone(public: boolean): Observable<any>
  • changePin(pin, repin, security_answer): Observable<any>
  • securityQuestion(): Observable<any>
  • setActiveGroup(group_id): Observable<any>
  • transactions(offset, limit, day): Observable<any>
  • transactionsPerDay(day: string | number, offset: number, limit: number): Observable<any>
  • createNewGroup(data: CreateGroupData): Observable<any> Security:
  • otp(): Observable<any>
  • request2faCode(): Observable<any>
  • validate2faCode(pin): Observable<any>
  • show2faCode(pin): Observable<any>
  • deactivate2faCode(pin): Observable<any>
  • getRecoveryCode(dni: string, phone: string, secret: string): Observable<any>
  • recoverPassword(code: string | number, password: string, repassword: string): Observable<any>

group

  • groups
  • group
  • update
  • users
  • creditCards
  • deleteCard
  • addCreditCard
  • updateLocation
  • bankAccount
  • addBankAccount
  • deleteBankAccount
  • offers
  • addOffer
  • editOffer
  • deleteOffer
  • categories
  • addCategory
  • products
  • addProduct
  • deleteProducts

transaction

  • getVendorData
  • recharge
map
  • list
  • search