Esempio n. 1
0
    def __init__(self, **kwargs):
        from highton.models import (
            Tag,
            ContactData,
            SubjectData,
        )

        self.author_id = fields.IntegerField(name=HightonConstants.AUTHOR_ID)
        self.background = fields.StringField(name=HightonConstants.BACKGROUND)
        self.created_at = fields.DatetimeField(
            name=HightonConstants.CREATED_AT)
        self.group_id = fields.IntegerField(name=HightonConstants.GROUP_ID)
        self.owner_id = fields.IntegerField(name=HightonConstants.OWNER_ID)
        self.updated_at = fields.DatetimeField(
            name=HightonConstants.UPDATED_AT)
        self.visible_to = fields.StringField(name=HightonConstants.VISIBLE_TO)
        self.linkedin_url = fields.StringField(
            name=HightonConstants.LINKEDIN_URL)
        self.avatar_url = fields.StringField(name=HightonConstants.AVATAR_URL)
        self.tags = fields.ListField(name=HightonConstants.TAGS,
                                     init_class=Tag)
        self.contact_data = fields.ObjectField(
            name=HightonConstants.CONTACT_DATA, init_class=ContactData)
        self.subject_datas = fields.ListField(
            name=HightonConstants.SUBJECT_DATAS, init_class=SubjectData)

        super().__init__(**kwargs)
Esempio n. 2
0
 def __init__(self, **kwargs):
     self.name = fields.StringField(name='name')
     self.created_date = fields.DateField(name='created-date')
     self.created_datetime = fields.DatetimeField(name='created-datetime')
     self.tags = fields.ListField(name='tags', init_class=Tag)
     self.category = fields.ObjectField(name='category', init_class=Category)
     super().__init__(**kwargs)
Esempio n. 3
0
    def __init__(self, **kwargs):
        self.body = fields.StringField(name=HightonConstants.BODY,
                                       required=True)
        self.author_id = fields.IntegerField(name=HightonConstants.AUTHOR_ID)
        self.subject_id = fields.IntegerField(name=HightonConstants.SUBJECT_ID,
                                              required=True)
        self.subject_type = fields.StringField(
            name=HightonConstants.SUBJECT_TYPE, required=True)
        self.subject_name = fields.StringField(
            name=HightonConstants.SUBJECT_NAME)
        self.collection_id = fields.IntegerField(
            name=HightonConstants.COLLECTION_ID)
        self.collection_type = fields.StringField(
            name=HightonConstants.COLLECTION_TYPE)
        self.visible_to = fields.StringField(name=HightonConstants.VISIBLE_TO)
        self.owner_id = fields.IntegerField(name=HightonConstants.OWNER_ID)
        self.group_id = fields.IntegerField(name=HightonConstants.GROUP_ID)
        self.updated_at = fields.DatetimeField(
            name=HightonConstants.UPDATED_AT)
        self.created_at = fields.DatetimeField(
            name=HightonConstants.CREATED_AT)
        self.attachments = fields.ListField(name=HightonConstants.ATTACHMENTS,
                                            init_class=Attachment)

        super().__init__(**kwargs)
    def list_notes(self, page=0, since=None):
        """
        Get the notes of current object

        :param page: the page starting at 0
        :type since: int
        :param since: get all notes since a datetime
        :type since: datetime.datetime
        :return: the notes
        :rtype: list
        """
        from highton.models.note import Note
        params = {'n': int(page) * self.NOTES_OFFSET}
        if since:
            params['since'] = since.strftime(self.COLLECTION_DATETIME)

        return fields.ListField(
            name=self.ENDPOINT,
            init_class=Note
        ).decode(
            self.element_from_string(
                self._get_request(
                    endpoint=self.ENDPOINT + '/' + str(self.id) + '/' + Note.ENDPOINT,
                    params=params
                ).text
            )
        )
Esempio n. 5
0
    def __init__(self, **kwargs):
        from highton import models

        self.name = fields.StringField(name=HightonConstants.NAME)
        self.users = fields.ListField(name=HightonConstants.USERS,
                                      init_class=models.User)

        super().__init__(**kwargs)
Esempio n. 6
0
    def __init__(self, **kwargs):
        """
        Init a deal with the attributes

        :param kwargs:
        :type kwargs:
        """
        from highton.models import (
            Tag,
            ContactData,
            SubjectData,
            Party,
            AssociatedParty,
            Category,
        )

        self.author_id = fields.IntegerField(name=HightonConstants.AUTHOR_ID)
        self.account_id = fields.IntegerField(name=HightonConstants.ACCOUNT_ID)
        self.background = fields.StringField(name=HightonConstants.BACKGROUND)
        self.category_id = fields.IntegerField(name=HightonConstants.CATEGORY_ID)
        self.created_at = fields.DatetimeField(name=HightonConstants.CREATED_AT)
        self.currency = fields.StringField(name=HightonConstants.CURRENCY)
        self.duration = fields.IntegerField(name=HightonConstants.DURATION)
        self.group_id = fields.IntegerField(name=HightonConstants.GROUP_ID)
        self.name = fields.StringField(name=HightonConstants.NAME)
        self.owner_id = fields.IntegerField(name=HightonConstants.OWNER_ID)
        self.party_id = fields.IntegerField(name=HightonConstants.PARTY_ID)
        self.price = fields.IntegerField(name=HightonConstants.PRICE)
        self.price_type = fields.StringField(name=HightonConstants.PRICE_TYPE)
        self.responsible_party_id = fields.IntegerField(name=HightonConstants.RESPONSIBLE_PARTY_ID)
        self.status = fields.StringField(name=HightonConstants.STATUS)
        self.status_changed_on = fields.DatetimeField(name=HightonConstants.STATUS_CHANGED_ON)
        self.updated_at = fields.DatetimeField(name=HightonConstants.UPDATED_AT)
        self.visible_to = fields.StringField(name=HightonConstants.VISIBLE_TO)
        self.party = fields.ObjectField(name=HightonConstants.PARTY, init_class=Party)
        self.category = fields.ObjectField(name=HightonConstants.CATEGORY, init_class=Category)
        self.tags = fields.ListField(name=HightonConstants.TAGS, init_class=Tag)
        self.parties = fields.ListField(name=HightonConstants.PARTIES, init_class=Party)
        self.contact_data = fields.ObjectField(name=HightonConstants.CONTACT_DATA, init_class=ContactData)
        self.subject_datas = fields.ListField(name=HightonConstants.SUBJECT_DATAS, init_class=SubjectData)
        self.associated_parties = fields.ListField(name=HightonConstants.ASSOCIATED_PARTIES, init_class=AssociatedParty)

        super().__init__(**kwargs)
Esempio n. 7
0
    def list(cls, params=None):
        """
        Retrieves a list of the model

        :param params: params as dictionary
        :type params: dict
        :return: the list of the parsed xml objects
        :rtype: list
        """
        return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
            cls.element_from_string(cls._get_request(params=params).text)
        )
Esempio n. 8
0
    def list_all(cls):
        """
        Returns a collection of all tasks visible to the current user.

        :return:
        :rtype: list
        """
        return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
            cls.element_from_string(
                cls._get_request(endpoint=cls.ENDPOINT + '/all').text
            )
        )
Esempio n. 9
0
    def list_today(cls):
        """
        Returns a collection of uncompleted tasks due for the rest of today for the authenticated user.

        :return:
        :rtype: list
        """
        return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
            cls.element_from_string(
                cls._get_request(endpoint=cls.ENDPOINT + '/today').text
            )
        )
Esempio n. 10
0
    def list_completed(cls):
        """
        Returns a collection of completed tasks.

        :return:
        :rtype: list
        """
        return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
            cls.element_from_string(
                cls._get_request(endpoint=cls.ENDPOINT + '/completed').text
            )
        )
Esempio n. 11
0
    def list_tags(self):
        """
        Get the tags of current object

        :return: the tags
        :rtype: list
        """
        from highton.models.tag import Tag
        return fields.ListField(name=self.ENDPOINT, init_class=Tag).decode(
            self.element_from_string(
                self._get_request(endpoint=self.ENDPOINT + '/' + str(self.id) +
                                  '/' + Tag.ENDPOINT, ).text))
Esempio n. 12
0
    def __init__(self, **kwargs):
        from highton.models import (
            PhoneNumber,
            TwitterAccount,
            WebAddress,
            EmailAddress,
            Address,
            InstantMessenger,
        )

        self.phone_numbers = fields.ListField(
            name=HightonConstants.PHONE_NUMBERS, init_class=PhoneNumber)
        self.twitter_accounts = fields.ListField(
            name=HightonConstants.TWITTER_ACCOUNTS, init_class=TwitterAccount)
        self.web_addresses = fields.ListField(
            name=HightonConstants.WEB_ADDRESSES, init_class=WebAddress)
        self.email_addresses = fields.ListField(
            name=HightonConstants.EMAIL_ADDRESSES, init_class=EmailAddress)
        self.addresses = fields.ListField(name=HightonConstants.ADDRESSES,
                                          init_class=Address)
        self.instant_messenger = fields.ListField(
            name=HightonConstants.INSTANT_MESSENGERS,
            init_class=InstantMessenger)

        for key, value in kwargs.items():
            setattr(self, key, value)
Esempio n. 13
0
    def list_upcoming(cls):
        """
        Returns a collection of upcoming tasks (tasks that have not yet been completed,
        regardless of whether they’re overdue) for the authenticated user

        :return:
        :rtype: list
        """
        return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
            cls.element_from_string(
                cls._get_request(endpoint=cls.ENDPOINT + '/upcoming').text
            )
        )
Esempio n. 14
0
 def get(cls, object_id):
     """
     Get all parties (people and companies) associated with a given tag.
     :param object_id: the primary id of the model
     :type object_id: integer
     :return: the parties
     :rtype: list
     """
     from highton.models.party import Party
     return fields.ListField(name=Party.ENDPOINT, init_class=Party).decode(
         cls.element_from_string(
             cls._get_request(endpoint=cls.ENDPOINT + '/' +
                              str(object_id)).text))
Esempio n. 15
0
    def list_assigned(cls):
        """
        Returns a collection of upcoming tasks (tasks that have not yet been completed,
        regardless of whether they’re overdue) that were created by the authenticated user,
        but assigned to somebody else.

        :return:
        :rtype: list
        """
        return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
            cls.element_from_string(
                cls._get_request(endpoint=cls.ENDPOINT + '/assigned').text
            )
        )
Esempio n. 16
0
    def __init__(self, **kwargs):
        from highton.models import (
            Party,
            AssociatedParty,
        )

        self.author_id = fields.IntegerField(name=HightonConstants.AUTHOR_ID)
        self.closed_at = fields.DatetimeField(name=HightonConstants.CLOSED_AT)
        self.created_at = fields.DatetimeField(
            name=HightonConstants.CREATED_AT)
        self.updated_at = fields.DatetimeField(
            name=HightonConstants.UPDATED_AT)
        self.name = fields.StringField(name=HightonConstants.NAME)
        self.visible_to = fields.StringField(name=HightonConstants.VISIBLE_TO)
        self.group_id = fields.IntegerField(name=HightonConstants.GROUP_ID)
        self.owner_id = fields.IntegerField(name=HightonConstants.OWNER_ID)
        self.background = fields.StringField(name=HightonConstants.BACKGROUND)
        self.parties = fields.ListField(name=HightonConstants.PARTIES,
                                        init_class=Party)
        self.associated_parties = fields.ListField(
            name=HightonConstants.ASSOCIATED_PARTIES,
            init_class=AssociatedParty)

        super().__init__(**kwargs)
    def list_comments(self, page=0):
        """
        Get the comments of current object

        :param page: the page starting at 0
        :return: the emails
        :rtype: list
        """
        from highton.models.comment import Comment
        params = {'page': int(page) * self.COMMENT_OFFSET}

        return fields.ListField(name=self.ENDPOINT, init_class=Comment).decode(
            self.element_from_string(
                self._get_request(endpoint=self.ENDPOINT + '/' + str(self.id) +
                                  '/' + Comment.ENDPOINT,
                                  params=params).text))
Esempio n. 18
0
    def search(cls, term=None, page=0, **criteria):
        """
        Search a list of the model
        If you use "term":
        - Returns a collection of people that have a name matching the term passed in through the URL.

        If you use "criteria":
        - returns people who match your search criteria.
        Search by any criteria you can on the Contacts tab, including custom fields. Combine criteria to narrow results

        :param term: params as string
        :type term: str
        :param criteria: search for more criteria
        :type criteria: dict
        :param page: the page
        :type page: int
        :return: the list of the parsed xml objects
        :rtype: list
        """

        assert (term or criteria and not (term and criteria))

        params = {
            'n': int(page) * cls.SEARCH_OFFSET,
        }

        if term:
            params['term'] = term

        if criteria:
            for key, value in criteria.items():
                params['criteria[{}]'.format(key)] = value

        return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
            cls.element_from_string(
                cls._get_request(endpoint=cls.ENDPOINT + '/search',
                                 params=params).text))