Module: Pastvu

Defined in:
lib/pastvu.rb,
lib/pastvu/model.rb,
lib/pastvu/parser.rb,
lib/pastvu/request.rb,
lib/pastvu/version.rb,
lib/pastvu/collection.rb,
lib/pastvu/photo/photo.rb,
lib/pastvu/configuration.rb,
lib/pastvu/basic_response.rb,
lib/pastvu/cluster/cluster.rb,
lib/pastvu/comment/comment.rb,
lib/pastvu/params_validator.rb,
lib/pastvu/photo/photo_collection.rb,
lib/pastvu/response/bounds_response.rb,
lib/pastvu/cluster/cluster_collection.rb,
lib/pastvu/comment/comment_collection.rb,
lib/pastvu/params_validator/type_check.rb,
lib/pastvu/params_validator/value_check.rb,
lib/pastvu/response/information_response.rb

Defined Under Namespace

Classes: BasicResponse, BoundsResponse, Cluster, ClusterCollection, Collection, Comment, CommentCollection, Configuration, InformationResponse, Model, ParamsValidator, Parser, Photo, PhotoCollection, Request, TypeCheck, ValueCheck

Constant Summary collapse

METHODS =
{
  photo_info:     "photo.giveForPage",
  comments:       "comment.giveForObj",
  nearest_photos: "photo.giveNearestPhotos",
  by_bounds:      "photo.getByBounds"
}
VERSION =
"1.0.2"

Class Method Summary collapse

Class Method Details

.by_bounds(geometry:, z:, **params) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/pastvu.rb', line 73

def self.by_bounds(geometry:, z:, **params)
  params[:localWork] = true if z >= 17

  params = {
    geometry:   geometry.instance_of?(Hash) ? geometry : Parser.to_hash(geometry),
    z:          z,
    isPainting: params[:isPainting] || params[:is_painting],
    year:       params[:year],
    year2:      params[:year2],
    localWork:  params[:localWork] || params[:local_work]
  }.compact

  ParamsValidator.validate params

  BoundsResponse.new request(__method__, params)
end

.comments(cid) ⇒ Object



46
47
48
49
50
51
52
53
54
# File 'lib/pastvu.rb', line 46

def self.comments(cid)
  params = {
    cid: cid
  }

  ParamsValidator.validate params

  CommentCollection.new request(__method__, params)
end

.configObject



94
95
96
# File 'lib/pastvu.rb', line 94

def self.config
  @config ||= Configuration.new
end

.configure(&block) ⇒ Object



98
99
100
# File 'lib/pastvu.rb', line 98

def self.configure(&block)
  config.configure(&block)
end

.nearest_photos(geo:, **params) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/pastvu.rb', line 56

def self.nearest_photos(geo:, **params)
  params = {
    geo:      geo,
    except:   params[:except],
    distance: params[:distance],
    year:     params[:year],
    year2:    params[:year2],
    type:     params[:type],
    limit:    params[:limit],
    skip:     params[:skip]
  }.compact

  ParamsValidator.validate params

  PhotoCollection.new request(__method__, params), params
end

.photo(cid) ⇒ Object



42
43
44
# File 'lib/pastvu.rb', line 42

def self.photo(cid)
  self.photo_info(cid).to_photo
end

.photo_info(cid) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/pastvu.rb', line 32

def self.photo_info(cid)
  params = {
    cid: cid
  }

  ParamsValidator.validate params

  InformationResponse.new request(__method__, params)
end

.request(method, params) ⇒ Object



90
91
92
# File 'lib/pastvu.rb', line 90

def self.request(method, params)
  Request.new(METHODS[method], params).response
end