music_today_api_wrapper 16.12.15.01 → 16.12.15.02

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa0ea07e0aed5d8eeda798c15fbc614756ccbd7a
4
- data.tar.gz: 7db1956f01e24cc6b0ce1fc640456db3ee4f4ecb
3
+ metadata.gz: effc5bf9a3a58bcc1f5007ef6c7e2a77e880f644
4
+ data.tar.gz: 6696f8fd1e8acf1ca717c88f0fc894f0c234e8dc
5
5
  SHA512:
6
- metadata.gz: 64a333c0c65288e05ac1a80a8013dcb21307766e28eef0c9dfd413156dccd8912248b3934f180cfb234c9b8b5178fc7df693bd2183836b398f07aa4df0f6dd4f
7
- data.tar.gz: 83403e14370e5c0722f16e233676346063586fe068c176b11351acb8ae71fc9369c6705a07738e3a3a5e561d04cd67d8a2dd63102c1757c959dd73bfc48604ca
6
+ metadata.gz: 7df24654c72e4d2987007cfa02e4ef508ca4e586d64194f1ebb4146eb74a67d522fe6c2006e083cca701074a25c9e8ce0e608071e8619b8b61e8204189791591
7
+ data.tar.gz: 826067c3af04fcfb1138cbd8864348cd09023646e74aae9420a84ee618919e81458a3b57b0b1fdd93ee135a9fd320ee575d1acf2cb1ac357e33606353bde1aff
@@ -1,10 +1,10 @@
1
1
  require 'rest_clients/music_today_rest_client'
2
2
  require 'resources/product'
3
3
 
4
- module MusicTodayApiWrapper
4
+ module MusicTodayApiWrapper::Domain
5
5
  class ProductServices
6
6
  def initialize
7
- @common_response = CommonResponse.new
7
+ @common_response = MusicTodayApiWrapper::RestClients::CommonResponse.new
8
8
  @common_response.data[:products] = []
9
9
  @rest_client = MusicTodayApiWrapper::RestClient.new
10
10
  end
@@ -21,7 +21,8 @@ module MusicTodayApiWrapper
21
21
  private
22
22
 
23
23
  def product_mapper(product)
24
- product_obj = Product.from_hash(product)
24
+ product_obj =
25
+ MusicTodayApiWrapper::Resources::Product.from_hash(product)
25
26
  @common_response.data[:products] << product_obj
26
27
  end
27
28
  end
@@ -12,7 +12,7 @@ module MusicTodayApiWrapper
12
12
  end
13
13
 
14
14
  def self.products
15
- product_services = ProductServices.new
15
+ product_services = Domain::ProductServices.new
16
16
  product_services.all_products
17
17
  end
18
18
  end
@@ -1,9 +1,11 @@
1
- class Image
2
- attr_accessor :short, :medium, :large
1
+ module MusicTodayApiWrapper::Resources
2
+ class Image
3
+ attr_accessor :short, :medium, :large
3
4
 
4
- def initialize(short = nil, medium = nil, large = nil)
5
- @short = short
6
- @medium = medium
7
- @large = large
5
+ def initialize(short = nil, medium = nil, large = nil)
6
+ @short = short
7
+ @medium = medium
8
+ @large = large
9
+ end
8
10
  end
9
11
  end
@@ -1,21 +1,24 @@
1
1
  require 'resources/image'
2
2
 
3
- class Product
4
- attr_accessor :name, :description, :category, :image
3
+ module MusicTodayApiWrapper::Resources
4
+ class Product
5
+ attr_accessor :name, :description, :category, :image
5
6
 
6
- def initialize(name, description, category, image = Image.new)
7
- @name = name
8
- @description = description
9
- @category = category
10
- @image = image
11
- end
7
+ def initialize(name, description, category,
8
+ image = MusicTodayApiWrapper::Resources::Image.new)
9
+ @name = name
10
+ @description = description
11
+ @category = category
12
+ @image = image
13
+ end
12
14
 
13
- def self.from_hash(product_hash)
14
- image = Image.new(product_hash['imageUrlSmall'],
15
- product_hash['imageUrlMedium'],
16
- product_hash['imageUrlLarge'])
15
+ def self.from_hash(product_hash)
16
+ image = Image.new(product_hash['imageUrlSmall'],
17
+ product_hash['imageUrlMedium'],
18
+ product_hash['imageUrlLarge'])
17
19
 
18
- Product.new(product_hash['name'], product_hash['lang']['en']['textDesc'],
19
- product_hash['categoryName'], image)
20
+ Product.new(product_hash['name'], product_hash['lang']['en']['textDesc'],
21
+ product_hash['categoryName'], image)
22
+ end
20
23
  end
21
24
  end
@@ -1,20 +1,22 @@
1
- class CommonResponse
2
- attr_accessor :data, :errors
1
+ module MusicTodayApiWrapper::RestClients
2
+ class CommonResponse
3
+ attr_accessor :data, :errors
3
4
 
4
- def initialize(data = {}, errors = [])
5
- @data = data
6
- @errors = errors
7
- end
5
+ def initialize(data = {}, errors = [])
6
+ @data = data
7
+ @errors = errors
8
+ end
8
9
 
9
- def work
10
- yield
11
- self
12
- rescue StandardError => error
13
- @errors.push(error.message)
14
- self
15
- end
10
+ def work
11
+ yield
12
+ self
13
+ rescue StandardError => error
14
+ @errors.push(error.message)
15
+ self
16
+ end
16
17
 
17
- def success?
18
- @errors.empty?
18
+ def success?
19
+ @errors.empty?
20
+ end
19
21
  end
20
22
  end
@@ -10,7 +10,7 @@ module MusicTodayApiWrapper
10
10
  @url = config.url
11
11
  @user = config.user
12
12
  @api_key = config.api_key
13
- @common_response = CommonResponse.new
13
+ @common_response = MusicTodayApiWrapper::RestClients::CommonResponse.new
14
14
  end
15
15
 
16
16
  def all_products
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: music_today_api_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.12.15.01
4
+ version: 16.12.15.02
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Gonzaga