apisync-rails 0.1.1 → 0.1.2

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: a583b9bcbe4c6e0dafb2d339832e45f00d10940c
4
- data.tar.gz: 767adc9866af63552c5bf288280a265e85e27a81
3
+ metadata.gz: 7e93409d7922bcdb80e2730e7c0b5cb0c3d4d742
4
+ data.tar.gz: 64742854d0a8c36263f5318bb73e71433f6bee83
5
5
  SHA512:
6
- metadata.gz: 0e10811ce56132875c6c302fe78575536f914237ced8a63aad970aea767f4862f4e1b09acdadcee083ddbd4675997060cd7aa746db6f5767e0a983cb4ca84f45
7
- data.tar.gz: '08476e75fd97d3068103a344304359fe7ff00eade77e99d63038f333fab71564dce0962272353edd76065df2f6d63d8653388c4ebe9d34f279fd14e7caf38d2f'
6
+ metadata.gz: f409dc9cb80cab5cbab1b3ca1ad6c79eccfe964c28cf81fc43a6823139b4646b35e19a79ff0fbce66232fc3a1673850673cbff093c7f4c02a27208902fef338b
7
+ data.tar.gz: d00e9310116b51fdddfd559ec2b98328506243f3581c55948418a38a91749862223f5df5ce52b77429208973c3990137bc4c95cc8bd8bb3d5272370cd1b60a11
data/README.md CHANGED
@@ -46,12 +46,12 @@ class Product < ActiveRecord::Base
46
46
  # remove it to always sync all items
47
47
  sync_if :should_sync?
48
48
 
49
- # required attributes
49
+ # Required attributes
50
50
  attribute :ad_template_type, from: :category
51
51
  attribute :available, from: :active?
52
52
  attribute :content_language, value: "pt-br"
53
53
 
54
- # recommended attributes
54
+ # Recommended attributes
55
55
  attribute :brand, from: :manufacturer
56
56
  attribute :condition, from: :normalize_condition
57
57
  attribute :description
@@ -63,8 +63,8 @@ class Product < ActiveRecord::Base
63
63
  attribute :title
64
64
  attribute :year
65
65
 
66
- # these are other attributes that you can send
67
- custom_attribute :city, name: :city_attr_name
66
+ # Custom attributes
67
+ custom_attribute :city, identifier: 'city-name', label: 'City name'
68
68
  end
69
69
 
70
70
  private
@@ -76,10 +76,10 @@ class Product < ActiveRecord::Base
76
76
  # required format (see reference docs)
77
77
  def images
78
78
  [{
79
- uri: "https://page.com/image1.jpg",
79
+ url: "https://page.com/image1.jpg",
80
80
  order: 1
81
81
  }, {
82
- uri: "https://page.com/image2.jpg",
82
+ url: "https://page.com/image2.jpg",
83
83
  order: 2
84
84
  }]
85
85
  end
@@ -92,10 +92,9 @@ class Product < ActiveRecord::Base
92
92
  }
93
93
  end
94
94
 
95
- # these give a human name to the custom attributes,
96
- # called based on :name parameters
97
- def city_attr_name
98
- "Delivery city"
95
+ # Custom attribute
96
+ def city
97
+ self.address.city
99
98
  end
100
99
  end
101
100
  ```
@@ -31,13 +31,14 @@ class Apisync
31
31
  @attributes[attr_name] = { attr_name: attr_name, from: from, value: value }
32
32
  end
33
33
 
34
- def custom_attribute(attr_name, from: nil, value: nil, name: nil)
34
+ def custom_attribute(attr_name, from: nil, value: nil, identifier: nil, label:)
35
35
  @attributes[:custom_attributes] ||= []
36
36
  @attributes[:custom_attributes] << {
37
37
  attr_name: attr_name,
38
38
  from: from,
39
39
  value: value,
40
- name: name
40
+ identifier: identifier,
41
+ label: label
41
42
  }
42
43
  end
43
44
 
@@ -91,14 +92,15 @@ class Apisync
91
92
  if attr == :custom_attributes
92
93
  custom_attrs = []
93
94
  properties.each do |custom_attr|
94
- from = custom_attr[:from]
95
- value = custom_attr[:value]
96
- attr_name = custom_attr[:attr_name]
97
- name = custom_attr[:name]
95
+ from = custom_attr[:from]
96
+ value = custom_attr[:value]
97
+ attr_name = custom_attr[:attr_name]
98
+ label = custom_attr[:label]
99
+ identifier = custom_attr[:identifier]
98
100
 
99
101
  custom_attrs << {
100
- name: localized_name(name),
101
- identifier: attr_name.to_s,
102
+ label: label || localized_name(name),
103
+ identifier: identifier || attr_name.to_s,
102
104
  value: attr_value(attr_name, from: from, value: value)
103
105
  }
104
106
  end
@@ -1,5 +1,5 @@
1
1
  class Apisync
2
2
  module Rails
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apisync-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre de Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-21 00:00:00.000000000 Z
11
+ date: 2018-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport