Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

[wip] Add SubClass abstract class #185

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

retrofox
Copy link
Contributor

Some methods / endpoints have the same pattern. For instance site.category, site.tag, site.media, site.post have get, add, update and delete methods. So to trying to reduce and simplify the code I've created this SubClass class. I am all ears to change its name.

import `SubClass` from `./subclass`;

class SiteCategory extends SubClass {
  constructor( slug, siteId, wpcom ) {
    super( {
      type: 'sites',
      subtype: 'categories',
      idBySlug: true,
      id: slug,
      baseId: siteId,
      wpcom
    } );
  }
}

// then ...

wpcom
  .site( 'es.blog.wordpress.com' )
  .category()
  .add( { name: 'Orange', description: 'Orange is the new black' } )
  .then( res => {
    // response is here ...
  } (
  .catch( err );

@retrofox retrofox force-pushed the update/site-methods branch 2 times, most recently from 271f49b to 9e1f7fe Compare April 18, 2016 20:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant