Example #1
0
    def resolve_voucher(self, info, **kwargs):
        voucher_user_id = self.voucher.auth0_user_id
        resp = requests.get(settings.V2_PROFILE_ENDPOINT).json()

        data = json2obj(json.dumps(resp))
        for profile in data:
            if profile['user_id']['value'] == voucher_user_id:
                return profile
        return None
Example #2
0
    def resolve_profile(self, info, **kwargs):
        """GraphQL resolver for a single profile."""

        resp = requests.get(settings.V2_PROFILE_ENDPOINT).json()

        data = json2obj(json.dumps(resp))
        user_id = kwargs.get('userId')
        for profile in data:
            if profile['user_id']['value'] == user_id:
                return profile
        return None
Example #3
0
    def resolve_profiles(self, info, **kwargs):
        """GraphQL resolver for the profiles attribute."""
        resp = requests.get(settings.V2_PROFILE_ENDPOINT).json()

        data = json2obj(resp)
        # Query based on user_id
        user_id = kwargs.get('userId')
        if user_id:
            for profile in data:
                if profile['user_id']['value'] == user_id:
                    return [profile]
            return None
        return data
Example #4
0
    def mutate(root, info, user_id, basic_profile_data=None):
        """Update the Basic information of a Profile."""

        resp = requests.get(settings.V2_PROFILE_ENDPOINT).json()

        data = json2obj(json.dumps(resp))
        for profile in data:
            # Get the profile with the specific userId
            if profile['user_id']['value'] == user_id:
                # Update the profile only if we have new data
                if basic_profile_data:
                    for k, v in basic_profile_data.items():
                        profile[k].update(v)
                return EditBasicProfile(updated_profile=profile)
        return None
Example #5
0
    def resolve_profiles(self, info, **kwargs):
        """GraphQL resolver for the profiles attribute."""
        resp = requests.get(settings.V2_PROFILE_ENDPOINT).json()

        return json2obj(json.dumps(resp))