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

orchextra-coupons-generation

v1.0.5

Published

Orchextra SDK para el consumo del módulo de Genereación.

Downloads

2

Readme

Orchextra-client-generation

Orchextra SDK para el consumo del módulo de Generación.

Instalación (npm)

npm install orchextra-coupons-generation

Ejemplos

Usuarios

var User = require('orchextra-coupons-generation/users');
var user = new User('https://generation-api-coupons.s.gigigoapps.com', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

Listado de Usuarios

var query = {
    _with: [],
    fields: ['role','name'],
    filter: {
      role: 'superadmin',
      name: 'Nehomar Correa'
    },
    page: 1,
    perPage: 5
};
user.all(query).then(users => {
    users.forEach((user) => console.log(user.data));
})
.catch(error => {
  console.log(error);
});

Información de Usuario

const id = '5942f7c73157b629aab3eae4';
user.get(id).then(returnedUser => {
  console.log(returnedUser);
})
.catch(error => {
  console.log(error);
});

Crear Usuario

var userModel = {
  name: 'Ricardo ',
  email: '[email protected]',
  username: 'Ricardo 4',
  role: 'Role',
  password: 'Password1',
  passwordConfirmation: 'Password1',
  languageCode: 'es',
  projectsIds: ["5936cb98d318c404f94951e2"]
};
user.create(userModel).then(user => {
  console.log(user);
}).catch(error => {
  console.log(error);
});

Eliminar Usuario

user.delete(id).then(user => {
  console.log(user);
})
.catch(error => {
  console.log(error);
});

Reemplazar Usuario

user.replace(userModel, id).then(user => {
  console.log(user);
}).catch(error => {
  console.log(error);
});

Actualizar Usuario

var userUpd = new User('https://generation-api-coupons.s.gigigoapps.com', 'XXXXXXXXXXXXXXXXXXXXX');
userUpd.data = {};
userUpd.data.email = '[email protected]';
userUpd.update(undefined, id).then(user => {
  console.log(user);
}).catch(error => {
  console.log(error);
});

Trabajar con objetos

Debido a que los métodos devuelven un objeto (en este caso del tipo "User"), es posible realizar acciones sobre ellos. Por ejemplo, eliminar un usuario de tu arreglo de usuarios. Para lo anterior, ya no es necesario enviar el id.


user.all(query).then(users => {  
  users.forEach((user) => console.log(user.data));
  users[4].delete().then(user => {
      console.log(user);
    })
    .catch(error => {
      console.log(error);
    });
})
.catch(error => {
  console.log(error);
});

También puedes, por ejemplo, actualizar un objeto de la siguiente forma


user.get(id).then(returnedUser => {
  returnedUser.data.name = 'Ricardo';
  returnedUser.data.username = '[email protected]';
  returnedUser.update().then(user => {
    console.log(user);
  }).catch(error => {
    console.log(error);
  });
})
.catch(error => {
  console.log(error);
});

Campañas

var Campaign = require('orchextra-client-generation/campaigns');
var campaign = new Campaign('https://generation-api-coupons.s.gigigoapps.com', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');

Listado de Campañas

var query = {
  _with: [],
  fields: ['image', 'description'],
  filter: {
    description: 'Esto es una prueba'
  },
  page: 2
};

campaign.all(query).then(campaigns => {
  campaigns.forEach((campaign) => console.log(campaign));
})
  .catch(error => {
    console.log(error);
  });

Información de Campaña

const id = '594beaff3157b629aab3eb5a';

campaign.get(id).then(campaignReturned => {
  console.log(campaignReturned);
})
.catch(error => {
  console.log(error);
});

Crear Campaña

var campaignModel = {
  type: "digital",
  name: "campaña nueva 4",
  legals: "Legales N",
  description: "Descripción Nueva 2",
  active: 'true',
  expirationDate: "2018-06-20T00:00:00.000Z",
  startDate: "2017-06-20T00:00:00.000Z",
  projectId: "5949957e3157b629aab3eb28",
  image: fs.createReadStream('facebook_318-136394.jpg')
};
campaign.create(campaignModel).then(campaign => {
  console.log(campaign);
}).catch(error => {
  console.log(error);
});

Eliminar Campaña

campaign.delete(id).then(campaign => {
  console.log(campaign);
})
.catch(error => {
  console.log(error);
});

Actualizar Campaña

campaign.update(campaignModel, id).then(campaign => {
  console.log(campaign);
})
.catch(error => {
  console.log(error);
});

Reemplazar Campaña

campaign.replace(campaignModel, id).then(campaign => {
  console.log(campaign);
})
.catch(error => {
  console.log(error);
});

Trabajar con objetos

Debido a que los métodos devuelven un objeto (en este caso del tipo "Campaign"), es posible realizar acciones sobre ellos. Por ejemplo, eliminar la campaña actual. Para lo anterior, ya no es necesario enviar el id.

campaign.get(id).then(campaignReturned => {
  console.log(campaignReturned);
  campaignReturned.delete().then(campaign => {
    console.log(campaign);
  })
  .catch(error => {
    console.log(error);
  });
})
.catch(error => {
  console.log(error);
});