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

node-madgex

v0.0.8

Published

node-madgex

Downloads

10

Readme

node-madgex

Build Status

A node.js client for Madgex web services.

About

Madgex's web services are split between RESTful and SOAP APIs. This module currently supports only a subset of the APIs, but we would be delighted to receive pull requests for the methods that are missing.

The current set of supported web services is

REST API

  1. getinfo
  2. employer
  3. myjobs

Billing API

  1. AddBilledJob
  2. AddRecruiterV2
  3. GetCategories
  4. GetCategoryTerms
  5. GetLocations
  6. UpdateBilledJob
  7. UpdateRecruiterWithBillingID
  8. AddPrePaidCredits
  9. CheckRecruiterExistsV2

The REST API

Usage

var madgex = require('node-madgex')
var client = madgex.createClient('http://yoursite-webservice.madgexjbtest.com',  { key: 'yourkey', secret: 'yoursecret' })

client.restApi.jobinfo({ jobid: 1257 }, function(err, data) {
    console.log(data);
})

API methods usually accept a params hash and a completion callback with (err, data, result) signature;

Promises

As an alternative to the completion callback you can use promises as well. Api methods return with a promise that resolves after the completion callback (if one is present).

client.jobinfo({ jobid: 1257 })
      .then(function(data) {
          //handle data
      })
      .fail(function(err) {
          //dome something with the error
      });

Chain'em

Promised values are easy to compose:

client.jobinfo
      .search({})
      .then(function(jobs) { return client.jobinfo({jobid: jobs[0].id }) })
      .then(function(jobdetails) { /*handle data*/ })
      .fail(function(err) { /*dome something with the error */ });

Service Description

The RESTful client API is dynamically built by code from the service description config file. Extend this to add new functions to the API. (/lib/rest-api-service-description.json)

Service Methods

jobinfo(params, done)

Displays information about a job

params

a hash with the following fields

field | type,info --- | --- jobid | integer, required

jobinfo.search(params, done)

Searches in the job database

params

field | type,info --- | --- keywords | free text with boolean expressions allowed, optional dateFrom | ISO format date dateTo | ISO format date

...and much more. refer to the Madgex REST documentation for full set of params.

jobinfo.search.full(params, done)

Same as search but returns full dataset

jobinfo.search.facets(params, done)

Return search refiners for a search result. Params are same as in search()

employer(params, done)

Displays information about am employer

params

a hash with the following fields

field | type,info --- | --- id | integer, required

employer.search(params, done)

Searches in the employer database

myjobs.add(params, done)

myjobs.delete(params, done)

The SOAP API

Usage

var madgex = require('node-madgex')
var client = madgex.createClient('http://yoursite-webservice.madgexjbtest.com',  { key: 'yourkey', secret: 'yoursecret' })

client.soapApi.billingApi.getCategoryTerms({ categoryId: 105 }, function(err, data) {
    console.log(data);
})

Each billingApi method takes an optional parameters object and typical callback. You can determine the available parameters names by inspecting the equivalent methods handlebars template (see ./lib/soap-templates/*.hbs). These are camel cased equivalents to the elements specified in the Madgex Billing API documentation. Working out which parameters are required and what their values should be requires a degree of experience.

Responses stripped of their SOAPiness and converted to camelCased json. Integers, floats and booleans are parsed, so instead of

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <GetCategoriesResponse xmlns="http://jobboard.webservice.madgex.co.uk">
            <GetCategoriesResult>
                <WSCategory>
                    <Mandatory>false</Mandatory>
                    <MultiSelect>true</MultiSelect>
                    <ID>105</ID>
                    <Name>Hours</Name>
                </WSCategory>
            </GetCategoriesResult>
        </GetCategoriesResponse>
    </soap:Body>
</soap:Envelope>

you'll receive

[
    {
        "mandatory": false,
        "multiSelect": true,
        "id": 105,
        "name": "hours"
    }
]

Error handling

In the event of an HTTP error, the err object passed to your callback will be blessed with a 'statusCode' property. In the event ofa SOAP Fault, the err object will additionally be blessed with 'faultCode' and 'faultString' properties.

Adding more SOAP API methods

Adding more API methods is easy

  1. Fork and clone node-madgex
  2. Generate a real request and response using your tool of choice (SoapUI, curl, etc)
  3. Convert the request to a handlbars template and save it in lib/soap-templates/MethodName.hbs,
  4. Save the response in test/replies/soap/MethodName.ok.xml
  5. Update lib/soap-api-service-description.json
  6. Add one or more test cases
  7. Submit a PR