Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 5.01 KB | None | 0 0
  1. package HelloWord;
  2. use Web::Simple;
  3.  
  4. use JSON::XS;
  5. use Digest::MD5 qw/md5_hex/;
  6. my $img = 'http://i.imgur.com/Ie2oDwW.jpg';
  7.  
  8. sub dispatch_request {
  9.     sub(POST + /mobile/login) {
  10.         [
  11.             200,
  12.             [ 'Content-type', 'application/json' ],
  13.             [
  14.                 encode_json(
  15.                     {
  16.                         api_key => md5_hex(rand),
  17.                         nome    => "Teste Fake",
  18.                         email   => 'nome_539-1@aoal.com',
  19.                         tipo    => "PF",
  20.                         id      => "288",
  21.                         sexo    => "F"
  22.  
  23.                     }
  24.                 )
  25.             ]
  26.         ];
  27.       }, sub(POST + /mobile/logout) {
  28.         [
  29.             200,
  30.             [ 'Content-type', 'application/json' ],
  31.             [
  32.                 encode_json(
  33.                     {
  34.                         ok => 1
  35.                     }
  36.                 )
  37.             ]
  38.         ];
  39.       }, sub(POST + /mobile/log) {
  40.         [
  41.             200,
  42.             [ 'Content-type', 'application/json' ],
  43.             [
  44.                 encode_json(
  45.                     {
  46.                         ok => 1
  47.                     }
  48.                 )
  49.             ]
  50.         ];
  51.       }, sub(GET + /mobile/ofertas) {
  52.         [
  53.             200,
  54.             [ 'Content-type', 'application/json' ],
  55.             [
  56.                 encode_json(
  57.                     {
  58.                         linhas => [
  59.                             {
  60.                                 imagem_icone      => $img,
  61.                                 imagem_pequena    => $img,
  62.                                 imagem_media      => $img,
  63.                                 imagem_grande     => $img,
  64.                                 url_compra        => 'http://google.com/',
  65.                                 preco_cheio       => '10.00',
  66.                                 preco_promocional => '9.80',
  67.                                 nome              => 'Ingresso Cinemark',
  68.                                 descricoes        => [
  69.                                     {
  70.                                         titulo   => 'Info Tecnicas',
  71.                                         conteudo => '220v bivolt 110 etc. etc..',
  72.                                     },
  73.                                     {
  74.                                         titulo   => 'Info Basiscas',
  75.                                         conteudo => 'wwwo <b> pode ter html aqui <b>',
  76.                                     },
  77.                                 ]
  78.                             },
  79.                            
  80.                             {
  81.                                 imagem_icone      => $img,
  82.                                 imagem_pequena    => $img,
  83.                                 imagem_media      => $img,
  84.                                 imagem_grande     => $img,
  85.                                 url_compra        => 'http://ig.com.br/',
  86.                                 preco_cheio       => '15.00',
  87.                                 preco_promocional => '15.80',
  88.                                 nome              => 'Titulo',
  89.                                 descricoes        => [
  90.                                     {
  91.                                         titulo   => 'Nonono',
  92.                                         conteudo => 'zooo',
  93.                                     },
  94.                                     {
  95.                                         titulo   => 'abc',
  96.                                         conteudo => 'wwwo',
  97.                                     },
  98.                                 ]
  99.                             }
  100.                    
  101.                         ] # fim linhas
  102.                     },
  103.                 )
  104.             ]
  105.         ];
  106.       }, sub(GET + /mobile/ajudometro) {
  107.         [
  108.             200,
  109.             [ 'Content-type', 'application/json' ],
  110.             [
  111.                 encode_json(
  112.                     {
  113.                         ajudometro => '101515.22',
  114.             quantidade_piggmes => '4567.33',
  115.                     }
  116.                 )
  117.             ]
  118.         ];
  119.       }, sub(POST + /mobile/esqueci_minha_senha) {
  120.         [
  121.             200,
  122.             [ 'Content-type', 'application/json' ],
  123.             [
  124.                 encode_json(
  125.                     {
  126.                         ok => '1'
  127.                     }
  128.                 )
  129.             ]
  130.         ];
  131.       }, sub(GET + /mobile/entidades) {
  132.         [
  133.             200,
  134.             [ 'Content-type', 'application/json' ],
  135.             [
  136.                 encode_json(
  137.                     {
  138.               linhas => [
  139.             {
  140.                 nome => 'Fundo Elas',
  141.                 id => '1223',
  142.                 imagem => $img
  143.             },
  144.             {
  145.                 nome => 'Projeto Arrastao',
  146.                 id => 1233,
  147.                 imagem => $img
  148.             }
  149.               ]
  150.                     }
  151.                 )
  152.             ]
  153.         ];
  154.       },   sub() {
  155.         [ 405, [ 'Content-type', 'text/plain' ], ['Method not allowed'] ];
  156.       }
  157. }
  158.  
  159. HelloWord->run_if_script;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement