Guest User

Untitled

a guest
Jul 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Newtonsoft.Json;
  4.  
  5. // Query start
  6.  
  7. namespace Generated
  8. {
  9. public interface IQuery
  10. {
  11. string GetQueryText();
  12. object GetParsedObject(string jsonText);
  13. }
  14.  
  15. public interface IQuery<T> : IQuery
  16. {
  17. new T GetParsedObject(string jsonText);
  18. }
  19. }
  20.  
  21.  
  22. namespace Generated.MyQuery
  23. {
  24.  
  25. /// <summary>Operation Type</sumary>
  26. public class Query : IQuery<Data>
  27. {
  28. private readonly int _id;
  29.  
  30. public Query(int id)
  31. {
  32. _id = id;
  33. }
  34.  
  35. public string GetQueryText()
  36. {
  37. return JsonConvert.SerializeObject(new
  38. {
  39. query = @"
  40. query MyQuery($id: Int = 1) {
  41. Property(propertyId: $id) {
  42. id
  43. name
  44. Continent {
  45. id
  46. name
  47. }
  48. Country {
  49. id
  50. Languages {
  51. languageId
  52. countryName
  53. }
  54. }
  55. Region {
  56. id
  57. name
  58. }
  59. State {
  60. id
  61. Languages {
  62. languageId
  63. stateName
  64. }
  65. }
  66. City {
  67. id
  68. Languages {
  69. languageId
  70. cityName
  71. }
  72. }
  73. Area {
  74. id
  75. name
  76. }
  77. }
  78. Languages {
  79. languageId
  80. name
  81. }
  82. }",
  83. variables = new {
  84. id = _id,
  85. }
  86. });
  87. }
  88.  
  89. public Data GetParsedObject(string jsonText)
  90. {
  91. return JsonConvert.DeserializeObject<Result>(jsonText).Data;
  92. }
  93.  
  94. string IQuery.GetQueryText()
  95. {
  96. return GetQueryText();
  97. }
  98.  
  99. Data IQuery<Data>.GetParsedObject(string jsonText)
  100. {
  101. return GetParsedObject(jsonText);
  102. }
  103.  
  104. object IQuery.GetParsedObject(string jsonText)
  105. {
  106. return GetParsedObject(jsonText);
  107. }
  108. }
  109.  
  110. public class Result
  111. {
  112. [JsonProperty("data")]
  113. public Data Data { get; set; }
  114. }
  115.  
  116. public class Data
  117. {
  118.  
  119. [JsonProperty("Property")]
  120. public Property Property { get; set; }
  121.  
  122. [JsonProperty("Languages")]
  123. public List<___Languages> Languages { get; set; }
  124. }
  125.  
  126. /// <summary>Inner Model</sumary>
  127. public class Property
  128. {
  129.  
  130. [JsonProperty("id")]
  131. public int Id { get; set; }
  132.  
  133. [JsonProperty("name")]
  134. public string Name { get; set; }
  135.  
  136. [JsonProperty("Continent")]
  137. public Continent Continent { get; set; }
  138.  
  139. [JsonProperty("Country")]
  140. public Country Country { get; set; }
  141.  
  142. [JsonProperty("Region")]
  143. public Region Region { get; set; }
  144.  
  145. [JsonProperty("State")]
  146. public State State { get; set; }
  147.  
  148. [JsonProperty("City")]
  149. public City City { get; set; }
  150.  
  151. [JsonProperty("Area")]
  152. public Area Area { get; set; }
  153. }
  154. /// <summary>Inner Model</sumary>
  155. public class Continent
  156. {
  157.  
  158. [JsonProperty("id")]
  159. public int Id { get; set; }
  160.  
  161. [JsonProperty("name")]
  162. public string Name { get; set; }
  163. }
  164. /// <summary>Inner Model</sumary>
  165. public class Country
  166. {
  167.  
  168. [JsonProperty("id")]
  169. public int Id { get; set; }
  170.  
  171. [JsonProperty("Languages")]
  172. public List<Languages> Languages { get; set; }
  173. }
  174. /// <summary>Inner Model</sumary>
  175. public class Languages
  176. {
  177.  
  178. [JsonProperty("languageId")]
  179. public int LanguageId { get; set; }
  180.  
  181. [JsonProperty("countryName")]
  182. public string CountryName { get; set; }
  183. }
  184. /// <summary>Inner Model</sumary>
  185. public class Region
  186. {
  187.  
  188. [JsonProperty("id")]
  189. public int Id { get; set; }
  190.  
  191. [JsonProperty("name")]
  192. public string Name { get; set; }
  193. }
  194. /// <summary>Inner Model</sumary>
  195. public class State
  196. {
  197.  
  198. [JsonProperty("id")]
  199. public int Id { get; set; }
  200.  
  201. [JsonProperty("Languages")]
  202. public List<_Languages> Languages { get; set; }
  203. }
  204. /// <summary>Inner Model</sumary>
  205. public class _Languages
  206. {
  207.  
  208. [JsonProperty("languageId")]
  209. public int LanguageId { get; set; }
  210.  
  211. [JsonProperty("stateName")]
  212. public string StateName { get; set; }
  213. }
  214. /// <summary>Inner Model</sumary>
  215. public class City
  216. {
  217.  
  218. [JsonProperty("id")]
  219. public int Id { get; set; }
  220.  
  221. [JsonProperty("Languages")]
  222. public List<__Languages> Languages { get; set; }
  223. }
  224. /// <summary>Inner Model</sumary>
  225. public class __Languages
  226. {
  227.  
  228. [JsonProperty("languageId")]
  229. public int LanguageId { get; set; }
  230.  
  231. [JsonProperty("cityName")]
  232. public string CityName { get; set; }
  233. }
  234. /// <summary>Inner Model</sumary>
  235. public class Area
  236. {
  237.  
  238. [JsonProperty("id")]
  239. public int Id { get; set; }
  240.  
  241. [JsonProperty("name")]
  242. public string Name { get; set; }
  243. }
  244. /// <summary>Inner Model</sumary>
  245. public class ___Languages
  246. {
  247.  
  248. [JsonProperty("languageId")]
  249. public int LanguageId { get; set; }
  250.  
  251. [JsonProperty("name")]
  252. public string Name { get; set; }
  253. }
  254. }
  255.  
  256. namespace Generated.UpdateStuff
  257. {
  258.  
  259. /// <summary>Operation Type</sumary>
  260. public class Mutation : IQuery<Data>
  261. {
  262. private readonly int _id;
  263.  
  264. public Mutation(int id)
  265. {
  266. _id = id;
  267. }
  268.  
  269. public string GetQueryText()
  270. {
  271. return JsonConvert.SerializeObject(new
  272. {
  273. query = @"
  274. mutation UpdateStuff($id: Int = 1) {
  275. ContractPropertyUpdateMutation(id: $id, userId: ""9d31af8d-a752-4a63-996a-019deb6cf269"", ipAddress: ""1.1.1.1"", userAgent: ""Some"") {
  276. id
  277. contractId
  278. hotelId
  279. }
  280. }",
  281. variables = new {
  282. id = _id,
  283. }
  284. });
  285. }
  286.  
  287. public Data GetParsedObject(string jsonText)
  288. {
  289. return JsonConvert.DeserializeObject<Result>(jsonText).Data;
  290. }
  291.  
  292. string IQuery.GetQueryText()
  293. {
  294. return GetQueryText();
  295. }
  296.  
  297. Data IQuery<Data>.GetParsedObject(string jsonText)
  298. {
  299. return GetParsedObject(jsonText);
  300. }
  301.  
  302. object IQuery.GetParsedObject(string jsonText)
  303. {
  304. return GetParsedObject(jsonText);
  305. }
  306. }
  307.  
  308. public class Result
  309. {
  310. [JsonProperty("data")]
  311. public Data Data { get; set; }
  312. }
  313.  
  314. public class Data
  315. {
  316.  
  317. [JsonProperty("ContractPropertyUpdateMutation")]
  318. public ContractPropertyUpdateMutation ContractPropertyUpdateMutation { get; set; }
  319. }
  320.  
  321. /// <summary>Inner Model</sumary>
  322. public class ContractPropertyUpdateMutation
  323. {
  324.  
  325. [JsonProperty("id")]
  326. public int Id { get; set; }
  327.  
  328. [JsonProperty("contractId")]
  329. public int ContractId { get; set; }
  330.  
  331. [JsonProperty("hotelId")]
  332. public int HotelId { get; set; }
  333. }
  334. }
  335.  
  336.  
  337. // Query end
Add Comment
Please, Sign In to add comment