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-mashov

v1.1.1

Published

A wrapper for Mashov API

Downloads

11

Readme

node-mashov

Build Status npm

A node.js wrapper for Mashov API.

Note that:

  • This wrapper focuses on student accounts, so don't expect for parental/teacher accounts support.
  • I was too scared to test messages sending, so there isn't such feature here.
  • I am not affiliated with Mashov in any way.

For a full list of features, consult the API section.

Install

Install it from npm:

npm install --save node-mashov

Or import it in the browser (from unpkg, for example):

<script src="https://unpkg.com/node-mashov/dist/node-mashov.min.js"></script>

<script>
  const { fetchSchools, Client} = window.nodeMashov;

  // ...
</script>

Usage

Example usage

import { fetchSchools, Client } from 'node-mashov';

(async () => {
  const schools = await fetchSchools();
  const school = schools.find(s => s.name.includes('myschool'));

  const client = new Client();

  client.login({
    username: 'username',
    password: 'supersecret',
    year: school.years[school.years.length - 1],
    school
  }).then(client.getGrades)
    .then((grades) => {
      console.log(grades);
    });
})();

API

Sample reponses from the API can be found here.

fetchSchools()

Returns a Promise for an Array of schools.

new Client()

Create a new client instance.

Client#getAuthDetails()

Client#setAuthDetails(authDetails)

After a successful login, an authDetails object is created, containing the required information for the client to authenticate with the API. You should store those details for future use.

authDetails

Type: Object

Client#setStartDate(startDate)

Client#setEndDate(endDate)

The API lets you specify time range for records. Those methods allows you to utilize this feture.

startDate, endDate

Type: string, null Format: YYYY-MM-DD

All of the following methods return a Promise

Client#login(userDetails)

Authenticate using the details provided in the constructor.

userDetails

Type: Object

username
password
year
school

Client#logout()

Deauthenticate and destroy authentication details.

Client#getConversations([query], [limit], [skip])

Getting the user's conversations.

query

Type: Object, string Default: 'inbox'

Mashov's API lets you query conversations. This wrapper does include support for that.

If query is a string, it'll fetch all of the messages matched the type. It could be one of the following:

  • 'inbox' - Inbox
  • 'archive' - Archived messages
  • 'unread' - Unread messages
  • 'deleted' - Deleted messages
  • 'sent' - Messages sent
  • 'draft' - Drafts

Otherwise, you can use a more complex query by making query into an object, with the following properties:

in

Type: string Default: 'all'

  • 'all' - All conversations
  • 'inbox' - Inbox
  • 'unread' - Unread messages
sender
receiver
subject
body

Type: string

attachment

Type: boolean Default: false

If true, will query all the conversations that has an attachment. If false, it'll query conversations with or without attachments.

fromDate
toDate

Type: string Format: YYYY-MM-DD

An example for a valid query:

{
  in: 'unread',
  sender: 'teacher',
  receiver: 'student',
  subject: 'Bring your books tomorrow',
  attachment: true,
  dromDate: '2017-05-01'
}
limit

Type: number Default: 20

Number of messages to fetch (from start).

skip

Type: number Default: 0

Number of messages to skip. Can be useful for pagination.

Client#getConversation(conversationId)

Fetch a single conversation.

Example usage:

client.getAllConversations()
  .then(convs => convs[0].id)
  .then(client.getConversation)
  .then((conv) => {
    console.log(conv);
  });

Client#getGrades()

Client#getBagrutGrades()

Client#getBehaveEvents()

Client#getLessonsCount()

Client#getOnlineLessons()

Client#getBells()

Will fetch the user's school's bell schedule.

Client#getTimetable()

Client#getFiles()

Will fetch the user's files (aka study materials)

Client#getGroups()

Client#getContacts()

Client#getGroupContacts()

Example usage:

client.getGroups()
  .then(groups => groups[0].id)
  .then(client.getGroupContacts)
  .then((contacts) => {
    console.log(contacts);
  });

See also

License

MIT © Yarden Sod-Moriah