Skip to content

Commit 677f726

Browse files
committed
add Shop Settings Update
new methods - update_shop_settings - update_shop_domain - update_shop_address
1 parent 0916ffd commit 677f726

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ As of now, `saleor-gql-loader` allows to create the following entities:
1515
- [x] product
1616
- [x] product_variant
1717

18+
and update the following entities:
19+
20+
- [x] shop
21+
1822
PR for supporting more graphQL mutations and/or queries are more than welcome.
1923

2024
In it's current state, the project is in very early alpha, might be unstable

saleor_gql_loader/data_loader.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,117 @@ def __init__(self, auth_token, endpoint_url="http://localhost:8000/graphql/"):
6565
self.headers = {"Authorization": "Bearer {}".format(auth_token)}
6666
self.endpoint_url = endpoint_url
6767

68+
def update_shop_settings(self, **kwargs):
69+
"""update shop settings.
70+
71+
Parameters
72+
----------
73+
**kwargs : dict, optional
74+
overrides the default value set to update the shop settings refer to the
75+
ShopSettingsInput graphQL type to know what can be overriden.
76+
77+
Raises
78+
------
79+
Exception
80+
when shopErrors is not an empty list
81+
"""
82+
83+
variables = {
84+
"shopSettingsInput": kwargs
85+
}
86+
87+
query = """
88+
mutation ShopSettingsUpdate($shopSettingsInput: ShopSettingsInput!) {
89+
shopSettingsUpdate(input: $shopSettingsInput) {
90+
shopErrors {
91+
field
92+
message
93+
code
94+
}
95+
}
96+
}
97+
"""
98+
99+
response = graphql_request(
100+
query, variables, self.headers, self.endpoint_url)
101+
102+
errors = response["data"]["shopSettingsUpdate"]["shopErrors"]
103+
handle_errors(errors)
104+
105+
def update_shop_domain(self, **kwargs):
106+
"""update shop domain.
107+
108+
Parameters
109+
----------
110+
**kwargs : dict, optional
111+
overrides the default value set to update the shop domain refer to the
112+
SiteDomainInput graphQL type to know what can be overriden.
113+
114+
Raises
115+
------
116+
Exception
117+
when shopErrors is not an empty list
118+
"""
119+
120+
variables = {
121+
"siteDomainInput": kwargs
122+
}
123+
124+
query = """
125+
mutation ShopDomainUpdate($siteDomainInput: SiteDomainInput!) {
126+
shopDomainUpdate(input: $siteDomainInput) {
127+
shopErrors {
128+
field
129+
message
130+
code
131+
}
132+
}
133+
}
134+
"""
135+
136+
response = graphql_request(
137+
query, variables, self.headers, self.endpoint_url)
138+
139+
errors = response["data"]["shopDomainUpdate"]["shopErrors"]
140+
handle_errors(errors)
141+
142+
def update_shop_address(self, **kwargs):
143+
"""update shop address.
144+
145+
Parameters
146+
----------
147+
**kwargs : dict, optional
148+
overrides the default value set to update the shop address refer to the
149+
AddressInput graphQL type to know what can be overriden.
150+
151+
Raises
152+
------
153+
Exception
154+
when shopErrors is not an empty list
155+
"""
156+
157+
variables = {
158+
"addressInput": kwargs
159+
}
160+
161+
query = """
162+
mutation ShopAddressUpdate($addressInput: AddressInput!) {
163+
shopAddressUpdate(input: $addressInput) {
164+
shopErrors {
165+
field
166+
message
167+
code
168+
}
169+
}
170+
}
171+
"""
172+
173+
response = graphql_request(
174+
query, variables, self.headers, self.endpoint_url)
175+
176+
errors = response["data"]["shopAddressUpdate"]["shopErrors"]
177+
handle_errors(errors)
178+
68179
def create_warehouse(self, **kwargs):
69180
"""create a warehouse.
70181

0 commit comments

Comments
 (0)