Пример #1
0
    def from_dict(fields: dict):
        """This allows you to create a BuycoinsPrice object using the fields in the data attribute of the dicts returned
           from BuycoinsGraphqlClient's methods. Study the methods of BuycoinsSDK to know how this is used

       Args:
           fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
       Returns:
           A BuycoinsPrice object
       """

        try:
            buycoins_price = BuycoinsPrice(
                node_id=fields['id'],
                buy_price_per_coin=fields['buyPricePerCoin'],
                cryptocurrency=fields['cryptocurrency'],
                expires_at=fields['expiresAt'],
                max_buy=fields['maxBuy'],
                max_sell=fields['maxSell'],
                min_buy=fields['minBuy'],
                min_coin_amount=fields['minCoinAmount'],
                min_sell=fields['minSell'],
                sell_price_per_coin=fields['sellPricePerCoin'],
                status=fields['status'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return buycoins_price
Пример #2
0
    def from_dict(fields: dict):
        """This allows you to create a Transaction object using the fields in the data attribute of the dicts returned
            from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

        Args:
            fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
        Returns:
            A Transaction object
        """
        try:
            tx = Transaction(
                node_id=fields['id'],
                address=Address.from_dict(fields['address']),
                amount=fields['amount'],
                confirmed=fields['confirmed'],
                created_at=fields['createdAt'],
                cryptocurrency=fields['cryptocurrency'],
                direction=fields['direction'],
                onchain_transfer_request_id=fields['onchainTransferRequest']
                ['id'],
                tx_hash=fields['txhash'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return tx
Пример #3
0
    def from_dict(fields: dict):
        """This allows you to create a PostOrder object using the fields in the data attribute of the dicts returned
            from BuycoinsGraphqlClient's methods. Study the methods of BuycoinsSDK to know how this is used

        Args:
            fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
        Returns:
            A PostOrder object
        """
        try:
            post_order = PostOrder(
                node_id=fields['id'],
                coin_amount=fields['coinAmount'],
                created_at=fields['createdAt'],
                cryptocurrency=fields['cryptocurrency'],
                dynamic_exchange_rate=fields['dynamicExchangeRate'],
                price_per_coin=fields['pricePerCoin'],
                price_type=fields['priceType'],
                side=fields['side'],
                static_price=fields['staticPrice'],
                status=fields['status'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return post_order
Пример #4
0
    def from_dict(fields: dict):
        """This allows you to create a PageInfo object using the fields in the data attribute of the dicts returned
           from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

       Args:
           fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
       Returns:
           A PageInfo object
       """

        try:
            return PageInfo(end_cursor=fields['endCursor'],
                            start_cursor=fields['startCursor'],
                            has_next_page=fields['hasNextPage'],
                            has_previous_page=fields['hasPreviousPage'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
Пример #5
0
    def from_dict(fields: dict):
        """This allows you to create an EstimatedFee object using the fields in the data attribute of the dicts returned
           from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

       Args:
           fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
       Returns:
           An EstimatedFee object
       """

        try:
            es_fee = EstimatedFee(estimated_fee=fields['estimatedFee'],
                                  total=fields['total'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return es_fee
Пример #6
0
    def from_dict(fields: dict):
        """This allows you to create an Account object using the fields in the data attribute of the dicts returned
            from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

        Args:
            fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
        Returns:
            An Account object
        """
        try:
            account = Account(node_id=fields['id'],
                              cryptocurrency=fields['cryptocurrency'],
                              confirmed_balance=fields['confirmedBalance'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return account
Пример #7
0
    def from_request_body(request_body: dict):
        """This allows you to create an Event object using the request body of a request from Buycoins

       Args:
           request_body: the request body from buycoins
       Returns:
           An Event object
       """
        try:
            event = Event(hook_id=request_body['hook_id'],
                          hook_key=request_body['hook_key'],
                          hook_time=request_body['hook_time'],
                          hook_signature=request_body['hook_signature'],
                          event_type=EventType(
                              request_body['payload']['event']),
                          data=request_body['payload']['data'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return event
Пример #8
0
    def from_dict(fields: dict):
        """This allows you to create a BankAccount object using the fields in the data attribute of the dicts returned
            from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

        Args:
            fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
        Returns:
            A BankAccount object
        """

        try:
            bank_account = BankAccount(
                node_id=fields['id'],
                account_name=fields['accountName'],
                account_number=fields['accountNumber'],
                account_reference=fields['accountReference'],
                account_type=fields['accountType'],
                bank_name=fields['bankName'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return bank_account
Пример #9
0
    def from_dict(fields: dict):
        """This allows you to create a PaymentConnection object using the fields in the data attribute of the dicts returned
           from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

       Args:
           fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
       Returns:
           A PaymentConnection object
       """

        try:
            p_edges = []
            pg_info = PageInfo.from_dict(fields['pageInfo'])
            payment_edges_dict = fields['edges']
            for i in payment_edges_dict:
                payment = Payment.from_dict(i['node'])
                p_edges.append(PaymentEdge(cursor=i['cursor'],
                                           payment=payment))

            return PaymentConnection(page_info=pg_info, payment_edges=p_edges)
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
Пример #10
0
    def from_dict(fields: dict):
        """This allows you to create a PostOrders object using the fields in the data attribute of the dicts returned
           from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

       Args:
           fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
       Returns:
           A PostOrders object
       """

        try:
            po_edges = []
            post_order_edges_dict = fields['orders']['edges']
            for i in post_order_edges_dict:
                post_order = PostOrder.from_dict(i['node'])
                po_edges.append(
                    PostOrderEdge(cursor=i['cursor'], post_order=post_order))
            return PostOrders(
                dynamic_price_expiry=fields['dynamicPriceExpiry'],
                page_info=PageInfo.from_dict(fields['orders']['pageInfo']),
                post_order_edges=po_edges)
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
Пример #11
0
    def from_dict(fields: dict):
        """This allows you to create an Order object using the fields in the data attribute of the dicts returned
            from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

        Args:
            fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
        Returns:
            An Order object
        """

        try:
            order = Order(node_id=fields['id'],
                          created_at=fields['createdAt'],
                          cryptocurrency=fields['cryptocurrency'],
                          filled_coin_amount=fields['filledCoinAmount'],
                          price=BuycoinsPrice.from_dict(fields['price']),
                          side=fields['side'],
                          status=fields['status'],
                          total_coin_amount=fields['totalCoinAmount'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return order
Пример #12
0
    def from_dict(fields: dict):
        """This allows you to create a Payment object using the fields in the data attribute of the dicts returned
           from BuycoinsGraphqlClient's methods. Study the methods of BuycoinsSDK to know how this is used

       Args:
           fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
       Returns:
           A Payment object
       """

        try:
            payment = Payment(node_id=fields['id'],
                              amount=fields['amount'],
                              created_at=fields['createdAt'],
                              fee=fields['fee'],
                              reference=fields['reference'],
                              status=fields['status'],
                              total_amount=fields['totalAmount'],
                              payment_type=fields['type'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return payment
Пример #13
0
    def from_dict(fields: dict):
        """This allows you to create an OnchainTransferRequest object using the fields in the data attribute of the dicts returned
            from BuycoinsGraphqlClient's methods.Study the methods of BuycoinsSDK to know how this is used

        Args:
            fields: the fields of the data property of a dict returned from a BuycoinsGraphqlClient method
        Returns:
            An OnchainTransferRequest object
        """

        try:
            onchain_transfer_request = OnchainTransferRequest(
                node_id=fields['id'],
                address=fields['address'],
                amount=fields['amount'],
                cryptocurrency=fields['cryptocurrency'],
                created_at=fields['createdAt'],
                fee=fields['fee'],
                status=fields['status'],
                transaction_id=fields['transaction']['id'])
        except KeyError as err:
            raise errors.MissingFieldException(err.args[0])
        else:
            return onchain_transfer_request