|
| 1 | +# Copyright 2018 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# pylint: disable=E1102 |
| 16 | +# python3 |
| 17 | +"""Retrieves customer data from our companies "internal" customer data serivce. |
| 18 | +
|
| 19 | +This data service is meant to be illustrative for demo purposes, as its just |
| 20 | +hard coded data. This can be any internal or on-premise data store. |
| 21 | +""" |
| 22 | + |
| 23 | + |
| 24 | +class CustomerDataService(object): |
| 25 | + _CUSTOMER_DATA = { |
| 26 | + 'mars': { |
| 27 | + 'customer_name': 'Mars Inc.', |
| 28 | + 'customer_logo': |
| 29 | + 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/' + |
| 30 | + 'OSIRIS_Mars_true_color.jpg/550px-OSIRIS_Mars_true_color.jpg', |
| 31 | + 'curr_q': 'Q2', |
| 32 | + 'curr_q_total_sales': '$2,532,124', |
| 33 | + 'curr_q_qoq': '0.054', |
| 34 | + 'prev_q': 'Q1', |
| 35 | + 'prev_q_total_sales': '$2,413,584', |
| 36 | + 'next_q': 'Q3', |
| 37 | + 'next_q_total_sales_proj': '$2,634,765', |
| 38 | + 'next_q_qoq_proj': '0.041', |
| 39 | + 'top1_sku': 'Phobos', |
| 40 | + 'top1_sales': '$334,384', |
| 41 | + 'top2_sku': 'Deimos', |
| 42 | + 'top2_sales': '$315,718', |
| 43 | + 'top3_sku': 'Charon', |
| 44 | + 'top3_sales': '$285,727', |
| 45 | + 'top4_sku': 'Nix', |
| 46 | + 'top4_sales': '$264,023', |
| 47 | + 'top5_sku': 'Hydra', |
| 48 | + 'top5_sales': '$212,361', |
| 49 | + }, |
| 50 | + 'jupiter': { |
| 51 | + 'customer_name': 'Jupiter LLC', |
| 52 | + 'customer_logo': |
| 53 | + 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/' + |
| 54 | + 'Jupiter_and_its_shrunken_Great_Red_Spot.jpg/660px-Jupiter_' + |
| 55 | + 'and_its_shrunken_Great_Red_Spot.jpg', |
| 56 | + 'curr_q': 'Q2', |
| 57 | + 'curr_q_total_sales': '$1,532,124', |
| 58 | + 'curr_q_qoq': '0.031', |
| 59 | + 'prev_q': 'Q1', |
| 60 | + 'prev_q_total_sales': '$1,413,584', |
| 61 | + 'next_q': 'Q3', |
| 62 | + 'next_q_total_sales_proj': '$1,634,765', |
| 63 | + 'next_q_qoq_proj': '0.021', |
| 64 | + 'top1_sku': 'Io', |
| 65 | + 'top1_sales': '$234,384', |
| 66 | + 'top2_sku': 'Europa', |
| 67 | + 'top2_sales': '$215,718', |
| 68 | + 'top3_sku': 'Ganymede', |
| 69 | + 'top3_sales': '$185,727', |
| 70 | + 'top4_sku': 'Callisto', |
| 71 | + 'top4_sales': '$164,023', |
| 72 | + 'top5_sku': 'Amalthea', |
| 73 | + 'top5_sales': '$112,361', |
| 74 | + }, |
| 75 | + 'saturn': { |
| 76 | + 'customer_name': 'Saturn', |
| 77 | + 'customer_logo': |
| 78 | + 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c7/' + |
| 79 | + 'Saturn_during_Equinox.jpg/800px-Saturn_during_Equinox.jpg', |
| 80 | + 'curr_q': 'Q2', |
| 81 | + 'curr_q_total_sales': '$2,532,124', |
| 82 | + 'curr_q_qoq': '0.032', |
| 83 | + 'prev_q': 'Q1', |
| 84 | + 'prev_q_total_sales': '$2,413,584', |
| 85 | + 'next_q': 'Q3', |
| 86 | + 'next_q_total_sales_proj': '$2,634,765', |
| 87 | + 'next_q_qoq_proj': '0.029', |
| 88 | + 'top1_sku': 'Mimas', |
| 89 | + 'top1_sales': '$334,384', |
| 90 | + 'top2_sku': 'Enceladus', |
| 91 | + 'top2_sales': '$315,718', |
| 92 | + 'top3_sku': 'Tethys', |
| 93 | + 'top3_sales': '$285,727', |
| 94 | + 'top4_sku': 'Dione', |
| 95 | + 'top4_sales': '$264,023', |
| 96 | + 'top5_sku': 'Rhea', |
| 97 | + 'top5_sales': '$212,361', |
| 98 | + }, |
| 99 | + 'neptune': { |
| 100 | + 'customer_name': 'Neptune', |
| 101 | + 'customer_logo': |
| 102 | + 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/' + |
| 103 | + 'Neptune_Full.jpg/600px-Neptune_Full.jpg', |
| 104 | + 'curr_q': 'Q2', |
| 105 | + 'curr_q_total_sales': '$2,532,124', |
| 106 | + 'curr_q_qoq': '0.027', |
| 107 | + 'prev_q': 'Q1', |
| 108 | + 'prev_q_total_sales': '$2,413,584', |
| 109 | + 'next_q': 'Q3', |
| 110 | + 'next_q_total_sales_proj': '$2,634,765', |
| 111 | + 'next_q_qoq_proj': '0.039', |
| 112 | + 'top1_sku': 'Triton', |
| 113 | + 'top1_sales': '$334,384', |
| 114 | + 'top2_sku': 'Nereid', |
| 115 | + 'top2_sales': '$315,718', |
| 116 | + 'top3_sku': 'Naiad', |
| 117 | + 'top3_sales': '$285,727', |
| 118 | + 'top4_sku': 'Thalassa', |
| 119 | + 'top4_sales': '$264,023', |
| 120 | + 'top5_sku': 'Despina', |
| 121 | + 'top5_sales': '$212,361', |
| 122 | + }, |
| 123 | + } |
| 124 | + |
| 125 | + def GetCustomerData(self, customer_id, properties): |
| 126 | + customer_data = self._CUSTOMER_DATA[customer_id] |
| 127 | + return [customer_data[p.lower()] for p in properties] |
0 commit comments